CString CString1;
string string1;
CHAR* char1=NULL;
一、CString转char*,string
//1。CString转string
string1=CString1.GetBuffer();
CString1.ReleaseBuffer();
//2。CString转CHAR*
char1=CString1.GetBuffer();
CString1.ReleaseBuffer();
二、string转char*,CString
//1。string转CString
CString1=string1.data();
//使用多字节编码
//2。sting转CHAR*
char1=new CHAR[string1.length()+1];
strcpy(char1,string1.data());
//使用Unicode编码
std::wstring string1 = _T("string");
WCHAR * char1 = _T("char1");
//2。sting转CHAR*
char1 = new WCHAR[string1.length() + 1];
wcscpy(char1,string1.data());
三、char* 转CString ,string
char1=_T("char1");
CString1=char1;
string1=char1;