书上说二维数组在内存中实际是以一维数组的形式连续存放的,我做了个小测试结果却令我无法理解。
#include <iostream>
using namespace std;
int main() {
int a[2][2] = {{0,1},{2,3}};
cout << &a << endl;
cout << a << endl;
cout << *a << endl;
cout << a[0] << endl;
cout << **a << endl;
cout << *(a[0]) << endl;
return 0;
}
输出:
0x7fff396c0210
0x7fff396c0210
0x7fff396c0210
0x7fff396c0210
0
0
那个内存地址处保存的是自己的地址?那么两次解引用不应该还是这个地址才对吗?怎么会变成0???
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…