everyone! I recently tried a piece of code from [C++ Primer, 5th edition]. This code is at chapter 3.
#include <iostream>
#include <string>
using std::string;
using std::cin;
using std::cout;
using std::endl;
int main()
{
string word;
while(cin >> word) {
cout << word << endl;
}
return 0;
}
Then, the book says: "...Once we hit end-of-file (or valid input), we fall out of the while." Surprisingly, I can never jump out from the while statement when trying this code in Visual Studio C++ 2017.
My question is: give what input will jump out from the loop? This book is very famous and read by many people, so I believe there is no error in the code.
Thank you!