#include<iostream>
#include<iomanip>
void main()
{
int i,j;
int pole[3][3]={1,2,3,4,5,6,7,8,9};
*(*(pole+2)+2)=0;
for(i=0; i<3;i++)
{
for(j=0;j<3;j++)
{
cout << setw(5)<< pole[i][j];
}
cout << endl;
}
}
This is my program, and the output I get is the following:
1 2 3
4 5 6
7 8 0
However, I am having trouble understanding what this line exactly means:
*(*(pole+2)+2)=0;
In my understanding, this is a pointer to an array pointer, so basically, the first one we do:
*(pole+2)
which points to the second element of the array. Then
*(*(pole+2)+2)
which points to the 4th element of the array? It's right? If so, how can we change the last element [3] [3] to 0?
Thank.
source
share