C++ string read string with blanks from standard input

Description

C++ string read string with blanks from standard input

#include <iostream>
using namespace std;
int main()/*from   w ww  . j  a  v a 2  s  .c om*/
{
   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;
}



PreviousNext

Related