© Ray Lischner 2020
R. LischnerExploring C++20https://doi.org/10.1007/978-1-4842-5961-0_5

5. Simple Input

Ray Lischner1 
(1)
Ellicott City, MD, USA
 

So far, the Explorations have focused on output. Now it’s time to turn your attention to input. Given that the output operator is <<, what do you expect the input operator to be? ________________

That didn’t take a rocket scientist to deduce, did it? The input operator is >>, the opposite direction of the output operator. Think of the operators as arrows pointing in the direction that information flows: from the stream to variables for input, or from variables to the stream for output.

Listing 5-1 shows a simple program that performs input and output.
import <iostream>;
int main()
{
   std::cout << "Enter a ...

Get Exploring C++20: The Programmer's Introduction to C++ now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.