Need helps on pointer

Hello,
I have some assignment questions on pointer and array, can anyone give me some suggest?
Please see the below codes:
int x[2][3] = {{4,5,2},{7,6,9}};
int (*p)[3] = &x[1];
cout << (*p)[0] << (*p)[1] << (*p)[2] <<;


is there any difference between (*p)[2] and *p[2] ??
And actually I have no idea on the above code,
Can anyone tell me what is the cout?
int (*p)[3] declares p as a pointer to an array of 3 int's.

p is then assigned to be the address of the x[1].

In other words, p points to the array of three integers 7,8,9

cout is the standard out stream in c++.

(*p)[2] means deference p and then take the third member of the array (i.e. 9)
*p[2] means take the third array member of p and then dereference it, but since p doesn't have 3 members, it will be dereferencing some random memory in the computer and most likely crash.

Topic archived. No new replies allowed.