I have the following program
#include<stdio.h>
int main() {
int a[3][3]={{1,2,3},
{4,5,6},
{7,8,9}};
printf("%p\n",a);
printf("%p\n",a[0]);
printf("%p\n",*(a+0));
}
And it gives me the following output:
6356716
6356716
6356716
I was expecting that, given a base address such as 6356716
then *(6356716+0)
would yield the value inside that location (i.e, 1
).
So, if an array name is equivalent to a pointer to its first value like in above expression, printing 'a' should print the pointer to its first value i.e a[0](which itself decays to its 1st element at location 6356716). In that case, why does dereferencing not work here, and *(a+0)
evaluates to
*(6356716+0)
?