一Unicode:
CString sSrc = _T("aa测试");
方法1:
char ch[10];
memset(ch,0,10);
memcpy(ch,sSep,sSep.GetLength());
char mychar = ch[0];//如果需要的话,只取第一个,
方法2:
char *p = NULL;
int nLength = sSrc.GetLength();
int nByte = WideCharToMultiByte(CP_ACP,0,sSrc,nLength,NULL,0,NULL,NULL);
p = new char[nLength + 1];
memset(ch,0,nLength + 1);
WideCharToMultiByte(CP_OEMCP,0,sSrc,nLength,p,nByte,NULL,NULL);
p[nByte]=0;
二、多字符集编码下:
方法1:
char *p;
CString str="hello";
p=str.GetBuffer(str.GetLength());
str.ReleaseBuffer();
方法2:
CString str="hello";
char ch[10];
memset(ch,0,10);
memcpy(ch,str,str.GetLength());
方法3:
char *ch;
CString str="hello";
ch=(LPSTR)(LPCTSTR)str;