Is it possible to use a variable in an array declaration such as:
char arr[number][20];
where number is a number found in an input file.
If so, I'd appreciate it if you let me know how.
Printable View
Is it possible to use a variable in an array declaration such as:
char arr[number][20];
where number is a number found in an input file.
If so, I'd appreciate it if you let me know how.
>Is it possible to use a variable in an array declaration
In the C89 standard, no. All array declarations must use an integer constant as the size. This changed with the C99 standard which does allow variables to be used as the size in an array declaration, but very few compilers conform to the new standard at this time.
In my personal opinion, this new feature is just a convenience that will complicate the language even more and was added for the benefit of novices since experienced programmers are familiar with getting around the restriction with relative ease.
So the answer to your question is no and yes depending on whether or not your compiler is C99 compliant :)
-Prelude