cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
UNIX/Linux Programming
relative path
relative path
Feb 29, 2012 at 4:05pm UTC
fafner
(377)
In my code I have a line similar to this:
fopen(
"../textures/test.bmp"
)
This works if I run the program from its own directory, however it doesnt find the file if I run it from any other directory. How can I make sure the program finds files relative to its own directory rather than the one I'm running it from?
Feb 29, 2012 at 4:07pm UTC
Athar
(4466)
By using absolute path names.
fopen((programDirectory+
"/../textures/test.bmp"
).c_str());
Feb 29, 2012 at 4:09pm UTC
fafner
(377)
Easy as that huh? :p I thought I was doing something wrong. Thanks! :)
Topic archived. No new replies allowed.