unsigned char *bySmgpMsgID [10]如其中内容是:0x02,0x50,0x06,0x06,0x02,0x08,0x56,0x14,0x82,0x70
如何转换成字符:02500606020856148270

解决方案 »

  1.   

    你要都是这样的很好做
    char strResult[30] = "";
    for(int i=0;i<10;++i)
        strcat(strResult,buSmgpMsgID[i]+2);
      

  2.   

    只要把0x02,0x50 前面的‘0x’去掉 
      

  3.   

    for中用CString 的%2X进行格式化
      

  4.   


    代码没问题  要仔细看 strcat(strResult,buSmgpMsgID[i]+2);改成
    strcat(strResult,bySmgpMsgID[i]+2);
      

  5.   

            char a=0x2F;
    CString b;
    b.Format ("%2X",a);
    ::AfxMessageBox (b);参考这个。
      

  6.   

    strcat(strResult,bySmgpMsgID[i]+2);
    报错
    'strcat' : cannot convert parameter 2 from 'int' to 'const char *'
      

  7.   

    len = strlen(bySmgpMsgID);
    for (i = 0; i <len; i++)
    {
         message.Format(_T("%02x"),bySmgpMsgID[i]);
         str += message;
    }str 里面保存的值就是你需要的
      

  8.   

    unsigned char bySmgpMsgID[10] = {0x02,0x50,0x06,0x06,0x02,0x08,0x56,0x14,0x82,0x70}; CString strTmp(_T(""));
    CString strText(_T(""));
    for(int i=0; i<sizeof(bySmgpMsgID)/sizeof(bySmgpMsgID[0]); i++)
    {
    strTmp.Format(_T("%02X"), bySmgpMsgID[i]);
    strText += strTmp;
    }
    AfxMessageBox(strText);