VS 2010 wstring未在输出窗口中显示

时间:2013-03-28 18:35:29

标签: c++ visual-studio-2010 wstring

我想输出一个wstring到输出窗口(我希望这是用英语调用的。)

enter image description here

但它没有那样做。

有人看到我哪里出错吗?

1 个答案:

答案 0 :(得分:1)

您可能想尝试使用OutputDebugString() Win32 API

在Unicode构建中,自VS2005以来一直是默认构建,OutputDebugString()扩展为OutputDebugStringW()(即 Unicode UTF-16版本的API,而ANSI版本是OutputDebugStringA())。

由于OutputDebugString[W]需要原始C字符串指针,您可以使用 std::wstring::c_str() 方法传递std::wstring的内容上述API:

// std::wstring sDebug
....
OutputDebugString( sDebug.c_str() ); // (is OutputDebugStringW() in Unicode builds)
相关问题