Arrays and Pointers

An array's identifier (name or label) is actually a pointer to the first element of an array. That is myArray === &myArray[0]  (or even &myArray ). The only difference is that the array name is a constant pointer (cannot change the location it points at).

 

int myArray[5] = {1, 2, 3, 4, 5} ;

 

The address of the first element is: &myArray[0]

 

Therefore &myArray[0] is the same as myArray, as are their addresses

 

The value in &myArray[0] is myArray[0], and the value in myArray is *myArray, and therefore myArray[0] is the same as *myArray

 

 

Leave a Reply