Mega Code Archive

 
Categories / C++ / Console
 

Unformattwd InputOutput

#include <iostream> #include <string> using namespace std; string header ="Unformatted Input"; int main() {    string word, rest;    cout << header << "Press <return> to go on" << endl;    cin.get();                  // Read the new line without saving.                                    cout << "\nEnter a sentence! End with <!> and <return>." << endl;    cin >> word;                // Read the first word    getline( cin, rest, '!');   // read a line up to the character !    cout << "The first word:   " << word  << endl         << "Remaining text: " << rest << endl;    return 0; }