This recipe focuses on console I/O. Most programs we write need some kind of interaction with the user: we need to get inputs, do some processing, and return the output. Think, for example, about user inputs you could collect in an application that you'll build. In this recipe, we'll write code that shows different ways to get input from the console and return the output.
Implementing I/O to and from the console
How to do it...
Let's write some code:
- With the Docker image running, let's create a new file named console_01.cpp and type this code into it:
#include <iostream>
#include <string>
int main ()
{
std::string name;
std::cout << "name: ";
std::cin >> name...