C++ program to read string with blank space and display in screen

//C++ program to read your full name (i.e. string with blank space) and display in screen

#include <iostream>
using namespace std;
int main()
{
    char name[20];
    cout<<"Enter your name: ";
    //cin>>name;
    cin.get(name,20); //cin.get(name,20,'\n'); \n is optional
    cout<<"Your name is: "<<name;
    return 0;
}

No comments:

Post a Comment