ifstream input;
int level;
cout<<"Which level would you like to play? \n"
<<"1.Easy"<<endl
<<"2.Medium"<<endl
<<"3.Hard";
cin>>level;
if(level = 1)
{
input.open("data.txt");
}
elseif(level = 2)
{
input.open("medium.txt");
}
elseif (level = 3)
{
input.open("hard.txt");
}
int r = 0;
int c = 0;
input>>r; //gets first number in file
input>>c; //gets second number in file
input.close();
The data.txt file has the coordinates (3,4)
The medium.txt file has the coordinates (4,4)
The hard.txt file has the coordinates (5,5)
However, when I print out the r and c variables, as the coordinates, they always print out 3,4, no matter what level I choose.