Reads string with embedded blanks using cin.get - C++ Data Type

C++ examples for Data Type:string

Description

Reads string with embedded blanks using cin.get

Demo Code

#include <iostream>
using namespace std;
int main()/*from  w  w  w  .  j av  a  2 s.co m*/
{
   const int MAX = 80;              //max characters in string
   char str[MAX];                   //string variable str
   cout << "\nEnter a string: ";
   cin.get(str, MAX);               //put string in str
   cout << "You entered: " << str << endl;
   return 0;
}

Result


Related Tutorials