I was learning about 2D arrays and pointer representation of it and all. I ran the following to get the internal working of 2d arrays. I got strange results for the arr2d[0]
int arr2d[2][3]{{1,2,3},{4,5,6}};
cout<<"&arr2d[0][0] :"<<&arr2d[0][0]<<endl;
cout<<"(&(arr2d[0])) :"<<(&(arr2d[0]))<<" arr2d[0] :"<<arr2d[0]<<endl;
cout<<"*(arr2d[0]) :"<< *(arr2d[0])<<" *(&(arr2d[0])) :"<<*(&(arr2d[0]))<<endl;
output:
&arr2d[0][0] :0x3e6d7ff6c0
(&(arr2d[0])) :0x44efbffbe0 arr2d[0] :0x44efbffbe0
*(arr2d[0]) :1 *(&(arr2d[0])) :0x44efbffbe0
How can *(arr2d[0]) have 1 as output, if arr2d[0] is "circularly pointing" itself? Also apparently pointer arthimetic is not functioning for arr[0], as arr[0]+1 doesn't gets one to arr[1].
I was not expecting the arr[0] to be circularly pointing to itself, I expected it to a pointer to a 1D array of length 3. this tells that this happens but I want to know why how can arr[0] point to itself but at the same time *(arr[0]) gives 1?