MFC中char*,string和CString之间的转换(待补充)

char*转化为CString

 

CString转化为char *

 

CString转化为wchar_t *:

wchar_t *pc = cStr.GetBuffer();

 

BYTE以数值的形式转化为CString,并拼接起来:

    CString cStr;
    BYTE * p3 = new BYTE[3];
    *p3 = 1;
    *(p3+1)=2;
    *(p3+2)=3;

    for (int i = 0; i < 3; i++)
    {
        CString cStr3;
        cStr3.Format(L"%02X", *(p3+i));    //一开始报错,加上L就好了
        cStr += cStr3;
    }

    wcout << "cStr:" << cStr.GetString() << endl;  //打印CString,
上一篇:【速贷客服电话】


下一篇:C++与C字符串相关知识点