What I need to do:
Read a text file of type ifstream called textFile
one character ch
at a time until ch
is equal to a single quotation mark '
. If ch is never equal to a quotation mark, print out fail and break out of the loop.
//read a character from the file into ch;
textFile.get(ch);
// while ch is not a single quote
while (ch != '\'')
{
//read in another character
textFile.get(c);
if (textFile.peek(), textFile.eof())
{
cout << "FAIL";
break;
}
}
The textFile.txt that I am reading from has NO single quotes, therefore the output should be FAIL.
However when I print it, it prints fail twice. Any help is appreciated