K
kc_student
Guest
Hello,
I'm taking a C Programming course and I'm new to the MS Visual Studio Community 2017 compiler. Anyway, I've seen this problem with const int declarations and their use in an array declaration like:
const int NUM_COUNTRY = 10;
const int MAX_COUNTRY_NAME_LENGTH = 50;
char ctryNames[NUM_COUNTRY][MAX_COUNTRY_NAME_LENGTH];
Once this code is compiled the following errors appear:
Severity Code Description Project File Line Suppression State
Error C2133 'ctryNames': unknown size
Error C2087 'ctryNames': missing subscript
Error C2466 cannot allocate an array of constant size 0
Error C2057 expected constant expression
How can this be fixed. In other compilers, this doesn't happen? What gives? Is their a compiler setting that can be altered
to prevent this error from occurring?
Thank you
Continue reading...
I'm taking a C Programming course and I'm new to the MS Visual Studio Community 2017 compiler. Anyway, I've seen this problem with const int declarations and their use in an array declaration like:
const int NUM_COUNTRY = 10;
const int MAX_COUNTRY_NAME_LENGTH = 50;
char ctryNames[NUM_COUNTRY][MAX_COUNTRY_NAME_LENGTH];
Once this code is compiled the following errors appear:
Severity Code Description Project File Line Suppression State
Error C2133 'ctryNames': unknown size
Error C2087 'ctryNames': missing subscript
Error C2466 cannot allocate an array of constant size 0
Error C2057 expected constant expression
How can this be fixed. In other compilers, this doesn't happen? What gives? Is their a compiler setting that can be altered
to prevent this error from occurring?
Thank you
Continue reading...