Domanda

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?

È stato utile?

Soluzione

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)
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top