当前位置: 动力学知识库 > 问答 > 编程问答 >

c++ - _wfreopen works on c:/path/file.txt but not with c:\path\file.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);

分享给朋友:
您可能感兴趣的文章:
随机阅读: