当我运行以下代码时,它适用于 C:
#include<stdio.h>
int main(void)
{
const int x=5;
char arr[x];
printf("%d",sizeof(arr));
}
但我不仅之前读过const
合格的变量不是real
常量(这就是为什么它们不能在case
条件下使用),而且来自IBMswitch-case
的以下链接证实了这一点(IBMLINK)并说:
const int k = 10;
int ary[k]; /* allowed in C++, not legal in C */
那么为什么允许我const
在 C 中使用限定变量作为数组大小而没有任何错误?