In my textbook, there is this example very similar this to reverse a line from an input file:
void Reverse(ifstream &inFile, int level)
{
int myInput = inFile.get();
if (myInput != '\n' && myInput != EOF) // don't understand this, line 4
Reverse(inFile, level);
if (myInput != EOF)
cout.put(myInput);
}
What I don't get is the line I commented. Because from an input file that's inputs were:
ABC\n
DEF\0
When the \n is equal to myInput, doesn't it make line 4's conditional statement become false since the first (myInput != '\n') would be false, and the second part (myInput != EOF) be true making that whole line false, and not calling the Reverse function again? Thanks.