C++ lpcwstr to wstring

tmighty picture tmighty · Apr 1, 2013 · Viewed 8.2k times · Source

I would like to convert a LPCWSTR to wstring in C++ (VS 2010). I want to use this in OutputDebugStringW().

Thank you.

Answer

Johnny Mnemonic picture Johnny Mnemonic · Apr 1, 2013

Well just pass the LPCWSTR to the constructor of wstring like this:

LPCWSTR str=L"fun";
wstring str2(str);