I have written following code in C++:
#include<iostream>
using namespace std;
int main()
{
int a[3]={2,3,1};
int (*ptr)[3];
ptr=&a;
for (int i = 0; i < 3; i++)
{
cout<<*ptr[i]<<" "<<ptr[i]<<" "<<&a[i]<<endl;
}
}
And my output is as follows:
2 0x61fe04 0x61fe04
6422020 0x61fe10 0x61fe08
2 0x61fe1c 0x61fe0c
I can understand that ptr contains the memory location of the array a as it points to the array.
But the array location(3rd col) and my pointer content (2nd col) is not a match.
and what is *ptr giving me?