1、CString转char*

#define SQL_QUERY_DATA "Select * from ShangxiaxianLog where clientid=\'%s\'"
CString str = _T("1234"); //定义CString字符串
USES_CONVERSION;
char* p = T2A(str.GetBuffer(0));
str.ReleaseBuffer();

char sql[MAX_PATH];
sprintf_s(sql, SQL_QUERY_DATA,p);

2、CString转int

CSet Dlg;
Dlg.DoModal();
CString strtest;
strtest = Dlg.str;
num = atoi(strtest);

3、char*转CString

char* pData = "1234";
CString strData(pData)