关于MFC程序中CString转char*与char*转CString的几个问题

Posted swust_wjy

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了关于MFC程序中CString转char*与char*转CString的几个问题相关的知识,希望对你有一定的参考价值。

一、CString转char*

char* Tool::CString2Char(CString msg)

	int len = WideCharToMultiByte(CP_ACP, 0, msg, -1, NULL, 0, NULL, NULL);
	char *buf = new char[len + 1];
	WideCharToMultiByte(CP_ACP, 0, msg, -1, buf, len, NULL, NULL);
	return buf;

二、char*转CString

char* a = “aaa”
CString str2(a);


以上是关于关于MFC程序中CString转char*与char*转CString的几个问题的主要内容,如果未能解决你的问题,请参考以下文章