#include <iostream> using namespace std; int main() { int arry[2][3] = { {2,3,5}, {6,7,8} }; cout << "二維數組大小 = "<< sizeof(arry) << endl; cout << "二維數組一行大小 = " << sizeof(arry[0]) << endl; cout << "二維數組元素大小 = " << sizeof(arry[0][0]) << endl; cout << "二維數組行數 = " << sizeof(arry) / sizeof(arry[0]) << endl; cout << "二維數組列數 = " << sizeof(arry[0]) / sizeof(arry[0][0]) << endl; //cout << "hello world!" << endl; //地址 cout << "二維數組首地址 = " << arry << endl; cout << "二維數組第一行地址 = " << arry[0] << endl; cout << "二維數組第二行地址 = " << arry[1] << endl; cout << "二維數組第一個元素地址 = " << &arry[0][0] << endl; cout << "二維數組第二個元素地址 = " << &arry[0][1] << endl; system("pause"); return 0; }
//===================================
#include <iostream>ios
using namespace std;數組
int main(){
int a = 0;
int arry[3][3] = {
{1,2,3},
{55,66,77},
{21,34,11}
};
cout << "輸出地址 = " << &arry << endl;
cout << "二維數組第一行 = " << arry[0] << endl;
cout << "二位數組行數 =" << sizeof(arry) / sizeof(arry[0]) << endl;
cout << "二位數組列數 =" << sizeof(arry[0]) / sizeof(arry[0][0]) << endl;
cout << "二位數組佔內存大小 =" << sizeof(arry) << endl;
cout << "二位數組一行佔內存大小 =" << sizeof(arry[0]) << endl;
cout << "二位數組總共佔內存大小 =" << sizeof(arry[0][0]) << endl;
spa
return 0;
}code