C++ examples for Data Type:string
Using an STL String for the your Name
#include <iostream> #include <string> using namespace std; int main(int argc, char *argv []) { cout << "Welcome to Text Adventure!" << endl << endl; cout << "What is your name?" << endl << endl; string playerName; /*w ww . ja va2 s . c o m*/ cin >> playerName; cout << endl << "Hello " << playerName << endl; return 0; }