C++: Where does the ofstream class save the files to?

Solution 1:

The stream classes, like all other file-opening functions, use the current directory when you provide a relative path. You can control the current directory with a function like chdir, but a better solution is to use fully qualified file names. Then you remove your program's dependency on the current directory.

Solution 2:

The file is simply created in the current working directory. Change working directory or provide full path.