C++, End to End
Input and Output Streams
std::cin, std::cout, and std::cerr have shown up throughout this course already. This chapter covers the parts of iostream that matter beyond the basics: formatting output precisely, reading input without your program falling over on bad data, and parsing text with string streams.
Stream manipulators
Manipulators like std::fixed and std::hex are sticky: they change the stream's state until you change it again. setw is the exception, it only applies to the very next thing written, which trips people up the first time they use it inside a loop and forget to repeat it.
Reading input safely
std::cin >> someInt fails cleanly (sets a fail flag) if the input isn't actually a valid integer, but it does NOT throw or crash, and the leftover bad input stays in the stream's buffer waiting to break your very next read too, unless you clear the state and discard it.
If you skip the clear()/ignore() pair after a failed read, the stream stays in a failed state forever: every subsequent >> silently does nothing, and you get an infinite loop that never actually prompts again. This is one of the most common real bugs in beginner C++ input code.
String streams for parsing
std::stringstream lets you use the exact same >> and << operators you already know, but against an in-memory string instead of the console. It's the standard tool for splitting a line into fields:
File I/O basics
std::ifstream and std::ofstream work like cin/cout once opened, since they're all built on the same iostream hierarchy. Always check whether the open actually succeeded before reading or writing; a missing file is a normal, expected failure mode, not an exceptional one.
Try it yourself: parse comma-separated values›
Use a stringstream and std::getline with a custom delimiter to split a comma-separated line into individual fields.