int main ()
{
namespace fs = std::filesystem;
try { // create directories tmp/test/ (if they don't exist yet):
fs::path testDir{"tmp/test"};
create_directories(testDir);
// create data file tmp/test/data.txt:
auto testFile = testDir / "data.txt";
std::ofstream dataFile{testFile};
if (!dataFile) {
std::cerr << "OOPS, can't open \"" << testFile.string() << "\"\n";
std::exit(EXIT_FAILURE); // exit program with failure
}
dataFile << "The answer is 42\n";