/*
* 二维数组数组名用途:
* 1、查看二维数组所占的内存空间
* 2、获取二维数组首地址
*/
#include<iostream>
using namespace std;
int main()
{
//二维数组组名
int arr[2][3] =
{
{1,2,3},
{4,5,6}
};
cout << "二维数组的大小: " << sizeof(arr) << endl;
cout << "二维数组一行的大小: " << sizeof(arr[0]) << endl;
cout << "二维数组元素的大小: " << sizeof(arr[0][0]) << endl;
cout << "二维数组行数: " << sizeof(arr) / sizeof(arr[0]) << endl;
cout << "二维数组列数: " << sizeof(arr[0]) / sizeof(arr[0][0]) << endl;
//地址
cout << "二维数组首地址: " << (int)arr << endl;
cout << "二维数组第一行地址: " << (int)arr[0] << endl;
cout << "二维数组第一行地址: " << (int)arr[1] << endl;
cout << "二维数组第一个元素地址: " << (int)&arr[0][0] << endl;
cout << "二维数组第二个元素地址: " << (int)&arr[0][1] << endl;
system("pause");
return 0;
}
|