User Input
Lesson 2 of 5 in Coddy's Simple Character Counter using C++ course.
Let's start!
You are probably familiar with using cin to get input:
string text;
cin >> text;But with the above way, if the user's input is Hello World, text will hold only Hello to get a full line from the user's input, use:
string text;
getline(cin, text);Or, if not using namespace:
std::string text;
std::getline(std::cin, text);Challenge
EasyCreate a program that outputs to the user (with a new line):
Enter text:And then it gets input from the user and saves it.
In the end, it outputs the user's input.
Try it yourself