这是如何实现的?我想用
pFile = fopen( file, "rb" );
其中 file 是一个 char、string 或 long 包含包含二进制文件的本地路径的文字文本
C:\Documents and Settings\Supernovah\Desktop\Supernovah.bin
但当然会崩溃。
我也对如何以可移植方式重复当前目录感兴趣。windows.h 有点难看,但如果我不能以便携的方式做到这一点。随它吧。
谢谢 :)
char* file="C:\\Documents and Settings\\Supernovah\\Desktop\\Supernovah.bin";
FILE* pFile = fopen( file, "rb" );
GCC/MinGW 和 VC++ 2008(可能还有其他)都允许在 Win32 中使用 Unix 风格的路径分隔符。所以:
char* file="C:/Documents and Settings/Supernovah/Desktop/Supernovah.bin";
也可以工作,并且可以在操作系统之间移植。然而,路径中的空格可能有问题,需要在 Linux 中用 %20 替换。