I understand that ptr
is a pointer to the address of M[0]
.
Therefore, I thought *ptr
would represent the value of M[0]
.
But why do the two show the same value?
Here's the code:
#include <iostream>
using namespace std;
int main(void) {
int M[3][3]={{1,2,3},{4,5,6},{7,8,9}};
int (*ptr)[3]; int *p; int **pt;
ptr = M;
cout << ptr << " " << *ptr;
return 0;
}
I look forward to a clear answer to this.
Also, I wonder how I can print out ptr[0]
.