在C中另一个目录中打开文件

Sup*_*vah 0 c binary fopen

如何实现的?我想用

pFile = fopen( file, "rb" );
Run Code Online (Sandbox Code Playgroud)

其中file是一个char,字符串或long,其中包含包含二进制文件本地路径的文字文本

C:\Documents and Settings\Supernovah\Desktop\Supernovah.bin
Run Code Online (Sandbox Code Playgroud)

但是当然会崩溃。

我也对如何以可移植的方式重现当前目录感兴趣。windows.h有点丑陋,但是如果我不能以便携式的方式做到这一点。随它吧。

谢谢 :)

CDR*_*CDR 5

char* file="C:\\Documents and Settings\\Supernovah\\Desktop\\Supernovah.bin";
FILE* pFile = fopen( file, "rb" );
Run Code Online (Sandbox Code Playgroud)