I defined a const int array like this :
const int arr[] = { 100 , 200, 300, 400 };
Now i want to set one of the elements of above array as the length of another array like the following :
char buffer[arr[3]];
But it gave me a compile time error :
non-constant arguments or reference to a non-constant symbol
I studied this This question to solve my problem but i became confuse about these questions :
- Why can't i set an element of a
constarray as the length of another array? - Are the elements of a
constarray constant or read only? - What is the differences between a
constand read only statements in c?
Regards!