Give an a basic set of C code:
int a = 5;
int b[a] = {1,2,3,4,5};
Why does this generate this error?
$gcc -o demo demo.c
error: variable-sized object may not be initialized
I understand that it is a bad thing to do and the compiler won't let you. However as a teacher I am having a hard time coming up with an explanation as to why you can not and should not do this.
(Assume C99)
How would you explain what is happening here?