Taking User Input
Learn how to use C++ cin and the extraction operator to capture user input and store it in variables. Understand how input works with different data types, including taking multiple inputs and handling whitespace limitations in console input.
We'll cover the following...
We'll cover the following...
In the previous chapter, we learned how the cout statement displays output to the console, but we did not discuss how it takes input in C++. In this lesson, we’ll explore how C++ uses its operators to take input from the user.
C++ input
C++ uses the statement cin and operator >> to get user input and store it in a memory location in C++. The basic syntax of how cin takes input is:
<cin> >> <variable_name> <;>
...