How to determine whether it is EOF when using getline() in c++?
c++, stream
Solution
Since I'm too lazy to give a full answer today, I'll just paste what the really useful bot in ##c++ on Freenode has to say:
Using "while (!stream.eof()) {}" is almost certainly wrong. Use the stream's state as the tested value instead: while (std::getline(stream, str)) {}. For further explanation see http://www.parashift.com/c++-faq-lite/input-output.html#faq-15.5
In other words, your code should be
string s;
while (getline(cin, s))
{
inputs.push_back(s);
}
Problem
``` string s; getline(cin,s); while (HOW TO WRITE IT HERE?) { inputs.push_back(s); getline(cin,s); } ```