#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>
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;
return 0;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/83174.html
標籤:C++
上一篇:day01
下一篇:QT程式自啟動
