
2010年8月22日
代碼1
const int size = 9;
char c[size];
1.VS2005 編譯為 C 代碼(/TC)
編譯不通過
錯誤 1 error C2057: expected constant expression
錯誤 2 error C2466: cannot allocate an array of constant size 0
錯誤 3 error C2133: 'c' : unknown size
2.VS2005 編譯為 C++ 代碼(/TP)
編譯通過
3.Cygwin gcc/g++
編譯通過
================================================
代碼2int temp = 9;
const int size = temp;
char c[size];
1.VS2005 編譯為 C 代碼(/TC)
編譯不通過
錯誤 1 error C2057: expected constant expression
錯誤 2 error C2466: cannot allocate an array of constant size 0
錯誤 3 error C2133: 'c' : unknown size
2.VS2005 編譯為 C++ 代碼(/TP)
編譯不通過
錯誤 1 error C2057: expected constant expression
錯誤 2 error C2466: cannot allocate an array of constant size 0
錯誤 3 error C2133: 'c' : unknown size3.Cygwin gcc/g++
編譯通過
================================================
代碼3int size;
scanf("%d", &size);
char c[size];
1.Cygwin gcc/g++
編譯通過
但不能對數組初始化。
2.VS2005
編譯不通過
posted @
2010-08-22 16:25 custa 閱讀(2098) |
評論 (3) |
編輯 收藏