int arr[][3] = {{1,3},{2,3},{6,7}};
cout << arr[0] << endl; // W/O col' somehow give you the address, not the element.
cout << arr[0][0] << endl;
我很好奇为什么 arr[0]
打印地址,而不是元素。
它似乎以某种方式忽略了它的取消引用运算符。
如果您能在指导或深度方面帮助我,我将不胜感激。
谢谢。
最佳答案
自 arr
是一个二维数组,arr[0]
将为您提供整行(更准确地说,是该行的地址)。
更准确地说,因为 arr
类型为 int[][3]
arr[0]
类型为 int[3]
, 衰减到 int *
.因此,cout << arr[0] << endl;
打印一个指针。
关于c++ - 没有列号的二维数组给出地址?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27728906/