[英]How to convert 'wchar_t *' to 'const char *'
How can I convert ' wchar_t
*' to ' const char *
' ? 如何将' wchar_t
*'转换为' const char *
'?
using C++ MFC VS2010. 使用C ++ MFC VS2010。
Thank you. 谢谢。
As the question is about MFC, I would suggest the following: 由于问题是关于MFC,我建议如下:
CStringA a = "Test";
CStringW w = L"Test";
a = CStringA(w);
w = CStringW(a);
I typically 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 operators LPCWSTR and LPCSTR respectivelly. CStringW和CStringA分别具有运算符LPCWSTR和LPCSTR。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.