This recipe will teach you the fundamental knowledge needed to deal with files. The C++ Standard Library historically offers a very good interface, but C++ 17 added a namespace called std::filesystem, which further enriches the offer. We'll not take advantage of the C++17 std::filesystem namespace, though, as it was already introduced in Chapter 2, Revisiting C++. Think about a concrete use case of creating a configuration file, or where you'd need to make a copy of that configuration file. This recipe will teach you how C++ makes this task easy.
Working with files
How to do it...
In this section, we'll write three programs to learn how to work with files by using std::fstream, std::ofstream,...