TCHAR finalpath[MAX_PATH];
GetCurrentDirectory(MAX_PATH,finalpath);
TCHAR filename[] = TEXT("\\lista.txt");
wcscat(finalpath,filename);
wprintf(L"List will be saved to %s", finalpath);
所以这基本上证实了我最终路径确实是 c:\somepath\lista.txt
但是 _wfreopen(TEXT(finalpath),TEXT("w"),stdout);
如果我把它改成
_wfreopen(TEXT("c:/somepath/lista.txt"),TEXT("w"),stdout);
然后一切正常,为什么以及如何让它接受我的 finalpath arg?
谢谢
最佳答案
不要将 TEXT 宏与变量一起使用。我很惊讶 _wfreopen(TEXT(finalpath),TEXT("w"),stdout);
甚至可以编译。
试试 _wfreopen(finalpath,TEXT("w"),stdout);
关于c++ - _wfreopen 适用于 c :/path/file. txt 但不适用于 c :\path\file. txt?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4589512/