c++ get user input string code example
Example 1: how to get string from user in cpp
string firstName;
cout << "Type your first name: ";
cin >>
firstName;
// get user input from the keyboard
cout << "Your name is: " <<
firstName;
// Type your first name: John
// Your name is: John
Example 2: input a string in c++
string fullName;
cout << "Type your full name: ";
getline (cin, fullName);
cout << "Your name is: " << fullName;