i have created a program on code blocks on mac that allows you to read contents from a file as well as write to them. i am able to read the file as well as write into it, but i couldnt seem to find the file itself unless i used spotlight. i thought the files created by ofstream were located in the same directory the project is in by default, but it is not there. what i would like to know is if there is a way to set the default location for files as the same directory for the project itself?
Asked
Active
Viewed 229 times
-2
-
I don't think so. `ofstream out(const char* location)` – Raindrop7 Oct 28 '16 at 22:41
-
There is no way to do this in the current C++ standard. Each OS has a different way to get the location of the running executable, and unfortunately, I don't know how to do it in a on a Mac. `_NSGetExecutablePath` looks promising, though. – user4581301 Oct 28 '16 at 23:41
1 Answers
1
i thought the files created by ofstream were located in the same directory the project is in by default
The file will be created at the default directory where your program is started, that's not necessarily the same as the directory of your IDE's project directory.
i would like to know is if there is a way to set the default location for files as the same directory for the project itself?
Most modern IDE's give you an option to change that from the defaults.

πάντα ῥεῖ
- 1
- 13
- 116
- 190