View Single Post
thuh Freak
Finally broke the seal
Join Date: May 2004
2007-05-03, 16:38

`relative paths` are relative to the current "working directory" of the application. in most *nix systems, you can find that with the PWD env variable. Theres no special thing to add for relative paths to work; it should be part of the standard libraries. The trick is knowing what your wd is. If you're good at terminal, you can run the program yourself:

cd /Users/myusername/Desktop/folder/ echo $PWD ./programName
the echo line proves that your working directory (ie, current folder) is what it is. if your files aren't opening right (or aren't saving anywhere reasonable), write this into your programs before your open/save calls:

#include <stdio.h> //put these with the rest of your inclues #include <stdlib.h> //... // put the following right before your relative path attempts fprintf( stderr, "cwd: %s\n", getenv("PWD") );
theres probably a better way to get the wd, but thats the first off my head. any attempt at a relative path after that call will be relative to what is printed on stderr.

i dont know from what directory xcode runs the programs, but that fprintf line should tell you.