Possible Duplicate:
Declaring an array with a non-constant size variable
This is my code:
const int xsize=150;
char Hey[xsize];
I don’t understand why I cannot declare my new array Hey using the constant above.
Can anyone help in this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s not valid C89 code. You can’t declare an array with variable size, even if the variable happens to be
const.It would work if you had it as a
#definerather than aconst int. It is valid in C99, though. GCC and other compilers also offer it as an extension in C89 mode.