请问有谁知道如何在VC++6.0中运行C语言中的变长数组?
程序是这样的:#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int i, n;
printf("How many numbers do you want to reverse: ");
scanf("%d", &n);
int a[n];
printf("Enter %d numbers: ", n);
for (i = 0; i < n; i++)
{
scanf("%d", &a[i]);
}
printf("In reverse order: ");
for (i = n-1; i>=0; i--)
{
printf("%d", a[i]);
}
printf("\n");
system("pause");
return 0;
}
编译显示:
--------------------Configuration: asasqasq - Win32 Debug--------------------
Compiling...
sadada.c
E:\安装位置\VC++6.0\测试\asasqasq\sadada.c(11) : error C2143: syntax error : missing ';' before 'type'
E:\安装位置\VC++6.0\测试\asasqasq\sadada.c(16) : error C2065: 'a' : undeclared identifier
E:\安装位置\VC++6.0\测试\asasqasq\sadada.c(16) : error C2109: subscript requires array or pointer type
E:\安装位置\VC++6.0\测试\asasqasq\sadada.c(16) : error C2102: '&' requires l-value
E:\安装位置\VC++6.0\测试\asasqasq\sadada.c(21) : error C2109: subscript requires array or pointer type
执行 cl.exe 时出错.
asasqasq.exe - 1 error(s), 0 warning(s)