As local variables are also called automatic variables, and are supposed to be allocated memory at run time, when function is accessed.
int main(){
int a; // declaration
return 0;
}
int main(){
int a[]; // compilation error, array_size missing
return 0;
}
int main(){
int a[2]; // declaration, but can't work without array_size,
// so at compile time it is checked!
return 0;
}
My question is whether it's just a rule to give array_size in declaration in C, or memory is allocated at compile time for array (still local variable)
How does it work?
An array is a variable as per C programming by K&R. pg no 161.