Input a string via cin. - C++ STL

C++ examples for STL:string

Description

Input a string via cin.

Demo Code

#include <iostream>
#include <string>
using namespace std;
int main()/*from  w w w  . j  av  a2 s.  co  m*/
{
   string str1("Alpha");
   string str2("Beta");
   string str3("Gamma");
   string str4;
   str4 = str1 + str3;
   cout << "Enter a string: ";
   cin >> str1;
   cout << "You entered: " << str1 << "\n\n";
   return 0;
}

Result


Related Tutorials