我读过 C89 不支持可变长度数组,但以下实验似乎反驳了这一点:
#include <stdio.h>
int main()
{
int x;
printf("Enter a number: ");
scanf("%d", &x);
int a[x];
a[0] = 1;
// ...
return 0;
}
当我这样编译时(假设文件名是va_test.c
):
gcc va_test.c -std=c89 -o va_test
有用...
我错过了什么?:-)