I read some topic about the relative path, but I'm still wrong. Hope sb can help me :). I am using Visual studio 2013, windows 7
I got the following directories:
Here is my .exe file D: \ uni \ C ++ \ ex5 \ msvc2013 \ ex5 \ Debug
Here is the file I want to read D: \ uni \ C ++ \ ex5 \ Res \ thehead.raw
Code to open the file:
FILE* f;
f = fopen("..\\..\\..\\res\\thehead.raw", "rb");
if (f == NULL)
printf("FAIL!!");
Since I need to use relative paths, I figured this out as follows: .. \ gets to the parent directory.
so that ".. \ .. \ .. \" should get into the folder "D: \ uni \ C ++ \ ex5 \".
\ res should open res foulder.
Needless to say, this fails, and I have no idea why. Any help would be appreciated.
source
share