I want to get the directory of a file which I created using ofstream. Code I wrote is something like
std::ofstream txt("sample.txt", std::ios::binary);
Then I write some things to the txt file, then call txt.close() to close the ofstream. While writing, I want to get the location of the sample.txt file and write it on to sample.txt. For example, the directory path would be like this:
/home/usr/Downloads/sample.txt
I want to save that whole thing as string so I can write it into sample.txt file. Can anyone help? I am using linux to code this, and a universal way to do this would be nice(working on windows, linux, mac etc).