Menu
Coddy logo textTech

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 icon

Challenge

Easy

Create 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

All lessons in Simple Character Counter using C++