问题难道在栈上也可以动态开辟数组了/*
* file: main.c
* author: 龙泉居士
* date: 2012-11-20 06:12
*/
#include <stdio.h>
int main ()
{
int n;
scanf ("%d", &n);
int a[n], i;
for (i=0; i!=n; ++i)
{
int x;
scanf ("%d", &x);
a[i] = x;
}
for (i=0; i!=n; ++i)
printf ("%d ", a[i]);
printf ("\n");
return 0;
} 无聊中写了一个程序居然编译通过运行正常,这这这。。。什么状况。。。整个三观都颠覆了,这样的程序不应该可以编译通过啊,难道在栈上也可以动态开辟数组? 解答Variable-length array,在这里有叙述:
For example, the GNU C Compiler allocates