solution for accept name from user in C++

Recommended Answers

Easy done via strings.

#include <iostream>
#include <string>
using namespace std;

int main(){
    string name;
    cout<<"Insert your name: ";
    cin>>name;
    cout<<"Hello "<<name<<".\n";
    return (0);
}
Jump to Post

All 2 Replies

You want the user to enter their name?

Easy done via strings.

#include <iostream>
#include <string>
using namespace std;

int main(){
    string name;
    cout<<"Insert your name: ";
    cin>>name;
    cout<<"Hello "<<name<<".\n";
    return (0);
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.