请高手指点:怎样将这样的一串字符挑中其中8个啊, 字符如下: 00 03 DF 66   00 03 81 A2   00 03 8B C5   FF FF F4 E9  重点在于字符的处理我不太会,比如说我选其中00 03 DF 66出来, 就是不会从这么多字符中选出这几个,左移右移,与运算等可以用么? 初学者,最好有代码提示啊!

解决方案 »

  1.   

    迷糊
    参考HexToDec(char *hex)
    {
    unsigned int n=0;
    for (char *tmp=hex; ; tmp++)
    {
    if (*tmp>='0' && *tmp <='9' )
    n = n*16 + *tmp-'0';
    else if (*tmp>='A' && *tmp <='Z')
    n = n*16 + *tmp-55;
    else if (*tmp>='a' && *tmp <='z')
    n = n*16 + *tmp-87;
    else
    break;
    }
    return n;

    参考
    CString a="010203040506";
    CString b=a.Left(2);
      

  2.   

    把十六进制表示的字符串"00 03 DF 66"转成十进制?
    CString strText(_T("0003DF66"));
    DWORD dwVal = _tcstoul(strText, NULL, 16);
    strText.Format(_T("%d"), dwVal);
    AfxMessageBox(strText);this??