_wfreopen 适用于 c:/path/file.txt 但不适用于 c:\path\file.txt? [英] _wfreopen works on c:/path/file.txt but not with c:\path\file.txt?

查看:38
本文介绍了_wfreopen 适用于 c:/path/file.txt 但不适用于 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);

所以这基本上证实了我的最终路径确实是 c:\somepath\lista.txt

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

但是 _wfreopen(TEXT(finalpath),TEXT("w"),stdout);

如果我只是把它改成

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

然后一切正常,为什么以及如何让它接受我的 finalpath arg?

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

谢谢

推荐答案

不要将 TEXT 宏与变量一起使用.我很惊讶 _wfreopen(TEXT(finalpath),TEXT("w"),stdout); 甚至可以编译.

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

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

这篇关于_wfreopen 适用于 c:/path/file.txt 但不适用于 c:\path\file.txt?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆