int const a=9;
int stack[a];
int main()
{
return 0;
}
The above code gives an error:variably modified 'stack' at file scope
But when I change the code to :
#define b 3
int stack[b];
int main()
{
return 0;
}
It compiles without error.While both #define and const variable are used for defining the constant identifier then why there is error when I use the const var instead of #define.I searched the similar question but all they gave solution about the error but no reason to it.
Searched about the const and #define and found that sometimes gcc compiler recognizes const as readonly but it is too confusing.