Possible Duplicate:
C: How come an array’s address is equal to its value?
int a[2];
printf("%u %u", (int)(&a), (int)(a));
I am thinking that &a is a pointer that points to the address of a. And the second a means the beginning address of the array.
Why are they the same?
In any context except where it is the operand of either the unary
&orsizeofoperators, the array nameaevaluates to a pointer to the first member of the array. This has typeint *.In
&a,astill designates the array itself, so&ais the address of the array. This has typeint (*)[2].Since the first element of the array is located at the beginning of the array, the address of the array and the address of the first element are necessarily coincident, so that’s why you see the same value.
(Really you should be using the
%pformat specifier to print pointers).