this code snippet compiles and runs fine
Code:
#include <stdio.h>
int main(void) {
int i, a[i];
i=2;
for(int n=0; n<=i; n++)
a[n]=0;
for(int n=0; n<=i; n++)
printf("%i ", a[n]);
printf("\n");
return 0;
}
it prints out 3 "0", but when slightly changed
Code:
#include <stdio.h>
int main(void) {
int i, a[i];
i=200;
for(int n=0; n<=i; n++)
a[n]=0;
for(int n=0; n<=i; n++)
printf("%i ", a[n]);
printf("\n");
return 0;
}
it compiles fine but core dumps when run, how come? i'm using gcc version 4.4.7, and compiling like this
gcc -std=c99 test.c -o test