在C中声明数组时,是否存在以下区别:
int someNumbersArray[] = {10, 20, 30};
以及:
int someNumbersArray[3] = {10, 20, 30};
?
I suppose that the result is the same after compilation. Maybe the latter is slightly faster during compilation?
我用一个由10000个数字组成的数组try 了上面的代码,没有看到任何区别.
PS:
- 声明大小太小的数组会导致问题(如果是这样,我使用的编译器会显示警告).
- 我知道您可以声明一个带有值的数组,并赋予它更大的大小;在这种情况下,显然您实际上必须声明所需的大小.