int a[2][2] = {{1, 2}, {3, 4}};
cout << a << endl;
cout << *a << endl;
cout << &a[0][0] << endl;
The output of this code is:
0x7fff3da96f40
0x7fff3da96f40
0x7fff3da96f40
However, if a is 0x7fff3da96f40 then *a should be the value in the address 0x7fff3da96f40 which is 1.
But, we get the same address again.
Why is this happening?
*a = 0and you see in the error message what*ais. This is not int.aisint (&)[2][2],*aisint(&)[2],a[0][0]is anint&. The first two decay to pointer.aisn't0x7fff3da96f40–ais not a pointer but an array. The value you see is its decay into a pointer to its first element,&a[0](and that first element is also an array that decays into a pointer to its first element when you print it).