// Example doseof.cpp // Show how to use the DOS Eof signal // Control-Z as a sentinel. #include #include using namespace std; int main() { string name; // The expression (cin >> name) returns // true if the read was successful and // false otherwise. If the user types // Control-Z; Return; Return, signalling // the end of the input, (cin >> name) // returns false. // Also try running this example from the // DOS Command Line with stdin and/or // stdout redirection. while(cin >> name) cout << "Hello, " << name << "." << endl; return EXIT_SUCCESS; }