[Cs3] Lab7 input loop

Mikhail Nesterenko mikhail at cs.kent.edu
Sun Jul 12 16:55:15 EDT 2015


> The input into vector tickets loop, from the lab link, does not actually
> catch the last line from the text file.  I had to move the: if
> (fin.eof())break; to after the: tickets.push_back(r);

The semantics of the extraction operator is to leave the unused white
space (including the newline character) in the stream. Hence,
fin.eof() will not return true once the last line of the file is read
with extraction operator since the newline character is still in the
stream. 

Now, you might have encountered (non-standard) behavior of Visual
Studio or, possibly, copied log.txt such that the last line just ends
with the last data token rather than a newline.

Thanks,
-- 
Mikhail


More information about the cs3 mailing list