How to convert a std::wstring
to a TCHAR*
? std::wstring.c_str()
does not work since it returns a wchar_t*
.
How do I get from wchar_t*
to TCHAR*
, or from std::wstring
to TCHAR*
?
use this :
wstring str1(L"Hello world");
TCHAR * v1 = (wchar_t *)str1.c_str();
#include <atlconv.h>
TCHAR *dst = W2T(src.c_str());
Will do the right thing in ANSI or Unicode builds.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With