Arrays

Type initialization / Collections

typedef struct {
    const char *firstName;
    const char *lastName;
} Employee;

//Array of integer
int primeNumbers[] = {2, 3, 5, 7, 11, 13, 17, 19};
//primeNumbers[2] is 5

//Array of string
const char *gameList[] = {"soccer", "hockey", "basketball"};
//gameList[1] is "hockey"

//Array of Employee struct, the fields by name
Employee employees[] = {
    {.firstName = "Anton", .lastName = "Pavlov"},
    {.firstName = "Elena", .lastName = "Kirienko"},
};
//employees[0].lastName is "Pavlov"

printf("primeNumbers[2] is %d\n", primeNumbers[2]);
printf("gameList[1] is %s\n", gameList[1]);
printf("employees[0].lastName is %s\n", employees[0].lastName);