Using an STL String for the your Name - C++ Data Type

C++ examples for Data Type:string

Description

Using an STL String for the your Name

Demo Code

#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; 
}

Result


Related Tutorials