Pointers and Array Names

An array name is (almost) equivalent to a pointer to the first element of the array.

For example given these declarations:

int *p;
int powers[8] = {1,2,4,8,16,32,64,128};
These two statements are equivalent:
p = &powers[0];  /* p now pointers to first array element  */
p = powers;      /* does exactly the same */ 

The only context where an array name is not equivalent to a pointer to the first element of the array, is where it is the argument of the sizeof operator.

Index