Author Topic: Help with ifstream/ofstream problem  (Read 3713 times)

chase_c

  • Guest
Help with ifstream/ofstream problem
« on: February 01, 2012, 02:48:01 am »
I am porting a project from windows to linux and the file IO is acting strange, or maybe I'm just assuming it is. The problem I'm facing is that I'm trying to load a text file using ifstream and no matter what I try I can't get the file to open, using relative or absolute filepaths. I have also tried to create a file using ofstream and it will not create the file while running the project from the IDE, but if I run the executable from the output directory it will create the file. Am I struggling with permissions or am I missing a step somewhere? I would paste the code here, but its just a simple declaration of an ifstream called file and file.open(fileName) and isOpen check that always fails. I'm always striving to better my communication skills so please let me know if I can clarify anything. Thanks.

Edit : It would seem after hours of scratching my head I found the answer tucked away in the project properties. In the Build Targets tab there is an option for Execution working directory and mine had defaulted to usr/bin instead of to the project directory. Changed that and everything is good now!
« Last Edit: February 01, 2012, 04:08:44 am by chase_c »