Reputation: 615
I'm learning C and now I'm having confusion in pointers. My question is, why doesn't printf("%d", *(i)); return the element instead of address while using multidimensional array??
#include <stdio.h>
int main()
{
int i[2][2] = {{1,8},{2,9},{3, 4}};
//int i[2] = {1,2,3};
printf("%d", *(i));
printf("\n%d", i);
}
Upvotes: 0
Views: 140
Reputation: 1966
Because a multidimensional array is can be written as **i so you doing *(i) gives you the address of the first array.
Upvotes: 1
Reputation: 210755
Well, it's an array of arrays, so indexing/dereferencing it once gives you an array, which decays to a pointer...
Upvotes: 6