方法一:
CString str = "Hello";
char * p1;
p1 = CW2A(str.GetBuffer(str.GetLength()));
注:这种方式转换因编码方式不同有可能出现乱码
方法二:
CString str = “Hello”;
char *p1 = new char[str.GetLength() + 1];(要申请空间)
memset(p1,0,str.GetLength() +1); (要进行初始化)
int nBytes = WideCharToMultiByte(CP_ACP,0,str,str.GetLength(),NULL,0,NULL,NULL);
WideCharToMultiByte(CP_OEMCP, 0, str, str.GetLength(), p1, nBytes, NULL, NULL);
注:这种方法稍微麻烦 乱码问题可以解决