是存放100个字符串的数组吗?
//通过
char* binary[100] = { "0", "00", "01", "10", "000", "001", "010", "011", "100",
"101", "110" };
//出错
char* binary[10] = { "0", "00", "01", "10", "000", "001", "010", "011", "100",
"101", "110" };
上面就不会出错,而下面就会出错,为什么?
is an array of pointers.
Each element in the array is of type char*, pointing to the first address of each string respectively.
The following array elements have more than 10 elements.
error C2078: too many initializers
The error is that there are too many initialization contents, because the length you declared is 10, and there are 11 contents in your initialization , this will cause the array to go out of bounds, so it cannot be compiled. However, because 100>11, the second line can be compiled and passed.
Modified
To put it simply, your code generates a two-dimensional array of char type. The first dimension is 10 and the second dimension is any length, which is char[10][]
So your program below is An error is reported if the length of one dimension exceeds 10