The Point of Arrays

Pointers and arrays in C share a peculiar bond. In fact, everything you do with arrays, you can do with pointers---sometimes more efficiently. The first connection between pointers and arrays is that the name of an array is really an expression for the pointer to its first element. For example:
int a[100], *p;
p = a;

is a perfectly valid declaration and statement and makes p point to the integer a[0] . Furthermore, we can actually index the pointer p . Continuing with the example above, the expressions p[5] and a[5] refer to exactly the same integer and p[125] and a[125] are both invalid references.

We'll see in the later sections other aspects of the connection between arrays and pointer. Things begin to get really complex when we look at the similarities and differences between arrays of pointers and multi-dimensional arrays (which are arrays of arrays).


In the code fragment:
p = &a[10];
printf("%d\n", p[5] );
which position in the array a will be printed?

10

5

15

14