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.

065 String streams istringstream to parse a line, ostringstream to build one, and a split that keeps numbers Open 066 iostream formatting width, precision, fill, base, boolalpha and why the flags stick Open 067 Text files ofstream, ifstream, getline, error checks and a file that is closed by its destructor Open 068 Binary files write and read raw bytes, seekg and tellg, and a struct that is not portable Open 069 std::filesystem paths, create_directories, directory_iterator, file_size and a recursive walk Open 070 Parsing a text file read a CSV line by line, split fields, convert numbers and report the bad line Open 071 Regular expressions std::regex_match, regex_search, capture groups and a log line that is split apart Open 072 Clocks and durations steady_clock, duration, milliseconds and a timing that measures real work Open 073 Calendar dates and formatting year_month_day, sys_days, zoned_time and std::format on a date Open 074 Random numbers mt19937, uniform_int_distribution, a seed and a shuffle Open 075 Bytes, code points and UTF-8 char against char32_t, UTF-8 sequences, u8string and counting code points Open 076 Arguments and environment argc and argv, std::string_view over the arguments, getenv and a small option parser Open

Lessons