Pointer to array of elements when dereferenced return an address. Since it is holding the address of the first element of the array, dereferencing it should return a value.
The behavior you see is a result of 'c' interpreting arr
as a pointer to the memory location of the first element. Pointer to the array &arr
will be an address of the array itself in memory, which is also the address of its first element. As a result arr
and &arr
yield the same values. Try this:
printf("array = %p, &array = %p\n", arr, &arr);
Thought the values are the same, types are different. arr
is a variable, whether &arr
is a pointer to the variable.
ptr
reflects the same picture. Its value ptr = &arr
makes it a pointer to an array. It contains the address of the array. *ptr
returns the array itself, which in 'c' interpretation is the address of the first element of the array. As a result values for ptr
and *ptr
are the same as for &arr
and arr
.
Hope it makes it clearer (not murkier) :-)