R.1 — iostream: printing and reading
Read one box at a time. No rush.
std::cout#
Print to the screen.
C++
std::cout << "Score: " << 10 << '\n';std::cin#
Read from the keyboard into a variable. Stops at spaces.
C++
int age {};std::cin >> age;std::getline#
Read a whole line, spaces included.
C++
std::string line {};std::getline(std::cin >> std::ws, line);std::cerr#
Print errors and debug messages. Shows up right away.
C++
std::cerr << "Something went wrong!\n";Formatting numbers#
Needs #include <iomanip>.
C++
std::cout << std::fixed << std::setprecision(2) << 3.14159; // 3.14std::cout << std::setw(5) << 42; // " 42"std::cout << std::boolalpha << true; // trueTip: press ← / → to move between lessons, / to search.