When I run the following code,it works fine for C:
#include<stdio.h>
int main(void)
{
const int x=5;
char arr[x];
printf("%d",sizeof(arr));
}
But not only had I read before that const
qualified variables are not real
constants (that's why they can't be used in case
condition of switch-case
),but the following link from IBM corroborates that (IBMLINK) and says:
const int k = 10;
int ary[k]; /* allowed in C++, not legal in C */
Why then am I allowed to use a const
qualified variable in C as an array size without any error?