How to convert 'wchar_t *' to 'const char *'

How can I convert ' wchar_t *' to ' const char * '?

using C ++ MFC VS2010.

Thanks.

+6
source share
2 answers

See the wcstombs functionality on MSDN.

+9
source

Since the question is about MFC, I would suggest the following:

 CStringA a = "Test"; CStringW w = L"Test"; a = CStringA(w); w = CStringW(a); 

I usually need the following conversions:

 CString t = _T("Test"); // depends on TCHAR type a = CStringA(t); // does not depend on TCHAR type w = CStringW(t); 

CStringW and CStringA have the LPCWSTR and LPCSTR statements.

+6
source

Source: https://habr.com/ru/post/899691/


All Articles