I am trying to read user input until ctrl-d is hit. If I am correct, ctrl+d emits an EOF signal so I have tried checking if cin.eof()
is true with no success.
Here is my code:
string input;
cout << "Which word starting which year? ";
while (getline(cin, input) && !cin.eof()) {
cout << endl;
...
cout << "Which word starting which year? ";
}
std::endl
is superfluous here, as flushing the stream is not needed. May be it could be good old'\n'
? endl is a source of performance problems – Leesa