int (*p)[4] , *ptr;
int a[4] = {10,20,30,40};
printf(\"%p\\n%p\\n%p\",&a,a,&a[0]);
p = &a ;
//p=a; gives error
//ptr = &a; gives error
ptr
I tried to understand what
a
,&a
, and&a[0]
are.
In C arrays decay to pointers. All of those pointers reference the same memory location (first element of the array). The only difference is the type.
a
and &a[0]
have the type of the array elements (in this case int
)
&a
is of type pointer to array of elements type (in this case array of 4 integers).