I'm trying to understand the below program. Specifically, the definition of cur_name and the incrementing of the pointer for cur_age in the printf statement.
*(cur_age + i) must be indexing each of the integers in the array but I would have expected this to point to successive addresses in memory and not the next integer given ints are 4 bytes? i.e. why not i+4
#include <stdio.h>
int main(int argc, char *argv[])
{
int ages[] = {23, 43, 12, 89};
char *names[] = {"Anne", "Kay", "Joe", "Pete"};
int count = sizeof(ages) / sizeof(int);
int *cur_age = ages;
char **cur_name = names;
for (int i = 0; i < count; i++) {
printf("%s is %d years old.\n", *(cur_name + i), *(cur_age + i));
}
return 0;
}