其他分享
首页 > 其他分享> > MFC中char*,string和CString之间的转换(待补充)

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,

标签:p3,cStr3,MFC,string,CString,char,cStr,BYTE
来源: https://www.cnblogs.com/Stephen-Qin/p/12186385.html