开发者

_wfreopen works on c:/path/file.txt but not with c:\path\file.txt?

开发者 https://www.devze.com 2023-02-02 01:31 出处:网络
TCHAR finalpath[MAX_PATH]; GetCurrentDirectory(MAX_PATH,finalpath); TCHAR filename[] = TEXT(\"\\\\lista.txt\");
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);

So this basically confirms me that finalpath is indeed c:\somepath\lista.txt

but _wfreopen(TEXT(finalpath),TEXT("w"),stdout);

开发者_开发问答

If i just change it to

_wfreopen(TEXT("c:/somepath/lista.txt"),TEXT("w"),stdout);

everything then works fine, why and how can i make it accept my finalpath arg?

Thanks


You don't use the TEXT macro with variables. I'm surprised that _wfreopen(TEXT(finalpath),TEXT("w"),stdout); even compiles.

Try _wfreopen(finalpath,TEXT("w"),stdout);

0

精彩评论

暂无评论...
验证码 换一张
取 消