0
根據我的理解,當我們定義一個數組時,我們需要明確指定它的大小,因爲編譯器會知道所需的內存被數組佔用。二維數組定義
因此,
案例1:
int a[][3]; //illegal as we will not know the size of the int array
a[0][1]=2;
a[1][3]=4;
然而,當我添加的東西是這樣的:
案例2:
int a[][3]={0}; //the compiler didn't complain at all
a[0][1]=2;
a[1][3]=4;
爲什麼不會編譯器顯示的錯誤信息在這種情況下?情況2中的定義僅告訴編譯器有多少列,但行數仍未知?編譯器不應該像案例1一樣行事?有任何理由來解釋這一點?謝謝你這麼多
確定'INT一個[] [3] = {0,2};''聲明A'是'的INT A [ 2] [3]'? – LogicStuff