Answers for "string input to user in c++ in class"

C++
16

user input c++

#include <iostream>
int main(){
  std::string firstname; //variable created as a string
  std::cout << "What's your first namen";
  std::cin >> firstname;//asking for the users' first name
  std:: cout << "Hello " << firstname
}
//Works for anyone, don't need any packages, just type this is in and run it.
Posted by: Guest on June-04-2020
17

input a string in c++

string fullName;
cout << "Type your full name: ";
getline (cin, fullName);
cout << "Your name is: " << fullName;
Posted by: Guest on May-04-2020

Browse Popular Code Answers by Language