Hi everyone.
I have a problem, It seems that the default directory for the files I want to read or write in is set on my Users directory (on mac).
I would like to be able to write relative path from somewhere inside my project folder. (On Xcode, the defaut settings for the files was the same folder as the .exe)
I've searched on forums and I read that changing the Execution Working Directory can resolve, but actually it doesn't (maybe I'm doing it wrong)
I'm with macOs 10.6.8 and code::blocks 13.12 (the latest I found for mac)
So here's my C++ code :
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ofstream monFlux("testReadFile.txt");
if(monFlux)
{
cout<<"ok!"<<endl;
monFlux<<"it works!!"<<endl;
}
else
{
cout<<"error file opening"<<endl;
}
return 0;
}
writing only the name of the file, it is created in /Users/myname/
So I tried to changed this Project>Properties>Build Targets >Execution Working Directory
it was .
I change to the absolute path I wanted as a root : /Users/myname/Documents/Programmation/LearningCpp/testReadFile/bin/Debug
here it propose two options relative or absolute, I tried both, the result is always the same, the file is created in /Users/myname/
If someone can help me I would be really grateful!
Thank you very much,
Rub