PDA

View Full Version : C++ Xcode file location help!




Concorde Rules
Nov 3, 2008, 06:09 PM
Basically this is for my aero eng course, so no changing coding language ;)

Im trying to open a file from where Xcode stores the executable, IE in the debug folder.

/* open file for input */
inf=fopen("datafile.txt","r");

Reads it from my home folder (Where the docs folder etc is).

I would like it to read from the Debug folder in the project folder.

I've tried a few things but with no success.

Anyone help?

Cheers!



Berlepsch
Nov 3, 2008, 07:46 PM
Did you try something like

fopen ("/this/is/the/path/to/my/Debug/file.txt", "r")

yet?

toddburch
Nov 4, 2008, 08:02 AM
When in doubt, print out your current working directory at runtime to see where it's set.

Concorde Rules
Nov 4, 2008, 08:21 AM
Edit: Ok, thats weird!!

Now it works with the full path where it didn't yesterday!!!

Oh well, all is good now.

Thanks people :)