I moved from Windows to Mac and now I'm experiencing a problem with the file input/output classes: ifstream
& ofstream
.
In Windows when you run with g++/Code Blocks
ofstream out("output.txt");
out << "TEST";
out.close();
A new file "output.txt" will be created in the same directory.
However in MAC OS X, this file is created in my home directory: /Users/USER_NAME/output.txt
How can I have this file in the same directory together with the executable?
P.S. I'm using GCC and CodeBlocks. There are no projects - I'm just compiling a single source file.
UPDATE
I just ran the same code in XCode, and it works ok! The files are created in project's Debug directory.
So it's not operating system's problem. It's Code::Blocks for Mac. How can I change work directory in Code::Blocks?