I am learning 2d array pointers and here is my code. I donot know why this line:
cout<<"Address of 1st part = "<<*ptr`
is not showing an address while this line is showing me address:
cout<<"Address of 1st part = "<<*(A)`
These both lines means same can any one help me.
#include <iostream>
using namespace std;
int main()
{
int A[2][3]={{1,2,4},{5,8,3}};
int *ptr;
ptr=&A[0][0];
cout<<"Address 1st part = "<<A<<endl;
cout<<"Address 2nd part = "<<A+1<<endl;
cout<<"Address 1st part = "<<ptr<<endl;
cout<<"Address 2nd part = "<<ptr+1<<endl;
cout<<"Address of 1st part = "<<*(A)<<endl;
cout<<"Address of 1st part = "<<*ptr<<endl;
cout<<"Address"<<*(A+1)+1<<endl;
cout<<*(A+1)+2<<endl;
return 0;
}
output
Address 1st part = 0x7fffb6c5f660
Address 2nd part = 0x7fffb6c5f66c
Address 1st part = 0x7fffb6c5f660
Address 2nd part = 0x7fffb6c5f664
Address of 1st part = 0x7fffb6c5f660
Address of 1st part = 1
Address0x7fffb6c5f670
0x7fffb6c5f674
*ptrresolves to typeint.*(A)resolves to typeint (&)[3]. they're not even close.