Text, streams and time
This part of the C++ course reads and writes text. A string stream parses a line in memory, the iostream flags format a table, and a file is opened, read line by line and closed by its destructor. The binary file, the recursive walk with std::filesystem and the CSV parser follow, then a regular expression and a log line taken apart. The part ends on time: a duration, a calendar date, a random number drawn with a seed, the bytes of UTF-8, and the arguments of main.
6.1
String streams
istringstream to parse a line, ostringstream to build one, and a split that keeps numbers
Open
6.2
iostream formatting
width, precision, fill, base, boolalpha and why the flags stick
Open
6.3
Text files
ofstream, ifstream, getline, error checks and a file that is closed by its destructor
Open
6.4
Binary files
write and read raw bytes, seekg and tellg, and a struct that is not portable
Open
6.5
std::filesystem
paths, create_directories, directory_iterator, file_size and a recursive walk
Open
6.6
Parsing a text file
read a CSV line by line, split fields, convert numbers and report the bad line
Open
6.7
Regular expressions
std::regex_match, regex_search, capture groups and a log line that is split apart
Open
6.8
Clocks and durations
steady_clock, duration, milliseconds and a timing that measures real work
Open
6.9
Calendar dates and formatting
year_month_day, sys_days, zoned_time and std::format on a date
Open
6.10
Random numbers
mt19937, uniform_int_distribution, a seed and a shuffle
Open
6.11
Bytes, code points and UTF-8
char against char32_t, UTF-8 sequences, u8string and counting code points
Open
6.12
Arguments and environment
argc and argv, std::string_view over the arguments, getenv and a small option parser
Open