I have written this piece of code:
where command is my file stream from text file, which looks exactly like this one:
if(command.is_open() == true)
while(command.eof() == false)
command >> instr;
command >> x;
The program is supposed to read the first line, and if it is 'r' then read also the second one which is the parameter for the 'r' instruction. At first, the eof returns false which is correct, however, after getting '1' from the file, and breaking from the switch instruction it goes back to the while statement where the eof evaluates false again, while after grabbing the last 1 it should evaluate for true. The result I am getting is that the program iterates through the 'r' switch two times, where it should be just one. How to make the eof evaluate true after getting the '1' from the file?