I am a new programmer and I am trying to set up my code so that when I input the values for rows and columns that I want my 2D array to have, I continue to run into this error:
error C2131: expression did not evaluate to a constant note: failure was caused by a read of a variable outside its lifetime
What I have so far is simple:
string cmd;
int R, C;
in >> cmd
while( !in.fail() )
{
if( cmd = "rows" )
{
in >> R;
}
if( cmd = "columns" )
{
in >> C;
}
in >> cmd;
}
char array[R][C];
When set up correctly, all the array[R][C] in my code will set the array to the [R][C] value from input similarly to how one would set the array to array[3][3] and such.
I am not sure how I should set this up so that my compiler understands I am trying to set my value set as constants, I appreciate any help. Thank you.
I am not allowed to use pointers or class/struct.