Getting user input in C++ [closed]
I am writing a program that allows a student to write a question and store that Question (or string) in a variable, can anyone please tell me the best way to get user input thanks for your answers and comments Formatted I/O; taken from Baby's First C++ : #include <string> #include <iostream> int main() { std::string name; std::cout << "Enter your name: "; std::getline(std::cin, name); std::cout << "Thank you, '" << name << "'." << std::endl; } This isn't quite satisfactory, as many things can (and thus will) go wrong. Here's a slightly more watertight version: int main() { std::string name;