I want to output a wstring to the output window (I hope that is what it is called in English).

enter image description here

But it does not do that.

Does anybody see where I went wrong?

有帮助吗?

解决方案

You may want to try using OutputDebugString() Win32 API.

In Unicode build, which has been the default since VS2005, OutputDebugString() expands to OutputDebugStringW() (i.e. the Unicode UTF-16 version of the API, while the ANSI version is OutputDebugStringA()).

Since OutputDebugString[W] expects a raw C string pointer, you can use std::wstring::c_str() method to pass the content of the std::wstring to the aforementioned API:

// std::wstring sDebug
....
OutputDebugString( sDebug.c_str() ); // (is OutputDebugStringW() in Unicode builds)
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top