printf("%p\n", arr);
printf("%p\n",*arr);
At the first example, arr
decays to a pointer to the first element in the first dimension of the two-dimensional array arr
(the first int
array of 5 elements - type (int[5]
)) which also decays to a pointer to its first element which is a[0][0]
.
At the second example you explicitly address the first element of the first dimension (which is of type int[5]
- int
array of 5 elements) and this one also decays to a pointer to its first element, which is again a[0][0]
.
So both have exactly the same result - Access and print the address of the first element of the first array at the first dimension of arr
- arr[0][0]
.
Note that you need to cast the pointer to void
, to make the program C-standard-conform as the standard implies that the %p
format specifier needs to have an associated argument of type void*
:
printf("%p\n", (void*) arr);
printf("%p\n", (void*) *arr);
Quote from ISO:IEC 9899:2018 (C18), Section 7.21.6.1/8:
"p - The argument shall be a pointer to void. The value of the pointer is converted to a sequence of printing characters, in an implementation-defined manner."