Unformattwd Input/Output: cin.get and getline : cout « Console « C++






Unformattwd Input/Output: cin.get and getline

Unformattwd Input/Output: cin.get and getline

#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;
} 


           
       








Related examples in the same category

1.Call function in coutCall function in cout
2.Use function in coutUse function in cout
3.Using the cout Object with Numeric ArraysUsing the cout Object with Numeric Arrays