C++ examples for STL:string
Input a string via cin.
#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; }