#include<iostream>
using namespace std;
int main()
{
int a[3][4] = {{1,3,5,7},{9,11,13,15},{17,19,21,22}};
int (* p)[4];
for(p = a; p < a + 3; p++)
{
cout << *(*(p + 0)) << " ";
cout << *p <<endl;
}
cout << endl;
return 0;
using namespace std;
int main()
{
int a[3][4] = {{1,3,5,7},{9,11,13,15},{17,19,21,22}};
int (* p)[4];
for(p = a; p < a + 3; p++)
{
cout << *(*(p + 0)) << " ";
cout << *p <<endl;
}
cout << endl;
return 0;
}
本来我是这么想的,令p = a后,p将指向二维数组中首元素的地址,而这个首元素是由4个整型元素组成的一维数组。想用cout << *p;输出每一行中的第一个元素,即a[0][0], a[1][0], a[2][0], 可是,为什么不管是cout << *p; 还是 cout << p; 都是输出地址信息