#include<stdio.h>
#include<stdlib.h>
struct haha
{
int a ;
int b;
};
#define MAX 100
#define MIN 10
void test(int a,int b)
{
int c = a*b+10;
struct haha array[c];
printf("size = %d\n",sizeof(array));
}
int main()
{
int a = 10;
int b = rand() % (MAX + 1 - MIN) + MIN;
printf("%d\n",b);
test(a,b);
return 0;
#include<stdlib.h>
struct haha
{
int a ;
int b;
};
#define MAX 100
#define MIN 10
void test(int a,int b)
{
int c = a*b+10;
struct haha array[c];
printf("size = %d\n",sizeof(array));
}
int main()
{
int a = 10;
int b = rand() % (MAX + 1 - MIN) + MIN;
printf("%d\n",b);
test(a,b);
return 0;
}
编译通过
C99标准是支持变长数组(VLA)的,但是vc10 不支持
gcc(MingW)编译通过