I know that int (*p)[5]
means a pointer which points to an array of 5 ints.
So I code this program below:
#include <iostream>
using namespace std;
int main()
{
int a[5]={0,1,2,3,4};
int (*q)[5]=&a;
cout<<a<<endl;
cout<<q<<endl;
cout<<*q<<endl;
cout<<**q<<endl;
return 0;
}
On my machine the result is:
0xbfad3608
0xbfad3608 //?__?
0xbfad3608
0
I can understand that *q
means the address of a[0]
and **q
means the value of a[0]
, but why does q
have the same value as a
and *q
? In my poor mind, it should be the address of them! I'm totally confused. Somebody please help me. Please!