Unformattwd Input/Output : cin « Console « C++






Unformattwd Input/Output

Unformattwd Input/Output
 

#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.cin to read float in C++cin to read float in C++
2.cin to readcin to read
3.Using the cin and cout Objects with ArraysUsing the cin and cout Objects with Arrays
4.cin and cout work with char arraycin and cout work with char array
5.cin Object's getline Functioncin Object's getline Function
6.Use the getline function to read the user's input and assign that input to the character array
7.A Closer Look at the I/O OperatorsA Closer Look at the I/O Operators
8.Filling an Array with a Maximum Number of Characters