C++ cin Read a line of text into string with getline function

Description

C++ cin Read a line of text into string with getline function

#include <iostream>
#include <string>
using namespace std;
int main()/*from w w w  . jav  a2  s .co m*/
{
   string message;     // declare a string object
   cout << "Enter a string:\n";
   getline(cin, message);
   cout << "The string just entered is:\n" << message << endl;
   return 0;
}



PreviousNext

Related