gcc - Is this a valid C program? -
i wrote program, size of array taken input user.
#include <stdio.h> main() { int x; scanf("%d", &x); int y[x]; /* stuff */ }
this program failed compile on school's compiler turbo c (an antique compiler). when tried on pc gnu cc, compiled successfully.
so question is, valid c program? can set size of array using user's input?
c90
not support variable length arrays can see using command line:
gcc -std=c90 -pedantic code.c
you see error message this:
warning: iso c90 forbids variable length array ‘y’ [-wvla]
but c99
valid:
gcc -std=c99 -pedantic code.c
Comments
Post a Comment