1 /* 2 数组名和指针相同吗? 3 */ 4 5 #include <iostream> 6 #include <cstdlib> 7 #include <cstdio> 8 9 using namespace std; 10 int a[][3] = {{1, 2, 3}, {1, 2, 3}, {4, 5, 6}, {3, 4, 5}}; 11 int sizef(int b[][3]) 12 { 13 cout << sizeof(b) << endl; 14 cout << sizeof(b[0]) << endl; 15 cout << sizeof(b)/sizeof(b[0]) << endl; 16 } 17 18 int main(void) 19 { 20 // int a[][3] = {{1, 2, 3}, {1, 2, 3}, {4, 5, 6}, {3, 4, 5}}; 21 22 23 cout << sizeof(a) << endl; 24 cout << sizeof(a[0]) << endl; 25 cout << sizeof(a)/sizeof(a[0]) << endl; 26 cout << "***********" << endl; 27 sizef(a); 28 // cout << sizef(a) << endl; 29 30 system("pause"); 31 return 0; 32 } 33
上面的程序的结果是:
48
12
4
***********
4
12
0