Read string and output - C++ File Stream

C++ examples for File Stream:cin

Description

Read string and output

Demo Code

#include <cstdlib> 
#include <iostream> 
#include <string>

using namespace std; 

int main(int argc, char *argv []) 
{ 
    string yourName; /* ww  w.j av a  2  s.c  om*/

    cout << "Please type your name and press Enter: " ;
    cin >> yourName; 

    cout << endl << "Hello, " << yourName << endl << endl; 

    cout << "Press c and then Enter to continue..."; 

    char justWait; 
    cin >> justWait; 

    return (0); 
}

Result


Related Tutorials