Using std::cin and std::cout Properly
Stream input and output with the standard streams and avoid common pitfalls.
The iostream Header
Both std::cin and std::cout are objects from the <iostream> header. They model the standard input and output streams of your terminal.
Output with std::cout
Stream values to std::cout with <<. It works for any type that has an operator<< overload — including all built-in types and std::string.
int age = 30;
std::string name = "Ada";
std::cout << "Name: " << name << ", Age: " << age << "\n";All lessons in this course
- Using std::cin and std::cout Properly
- Formatting Output with iomanip
- Reading Input Safely with getline
- Working with std::cerr and std::clog