如:
ASCII的 "AE 11 56 A6"  转换成 1010 1110 0001 0001 0101 0110 1010 0110
或是 16进制 AE 11 56 A6 也可以。谢谢!

解决方案 »

  1.   

    CString strAscii;
    strAscii = "AE 11 56 A6";
    int nLength = strAscii.GetLength();
    UINT uRes = 0;
    for (int i = 0; i < nLength; i++)
    {
      uRes *= 16;
      if (strAscii[i] >= '0' && strAscii[i] <= '9')
        uRes += strAscii[i] - '0';
      else if (strAscii[i] >= 'a' && strAscii[i] <= 'f')
        uRes += strAscii[i] - 'a' + 10;
      else if (strAscii[i] >= 'A' && strAscii[i] <= 'F')
        uRes += strAscii[i] - 'A' + 10;
    }prinf("0x%08X\n", uRes);
      

  2.   

    char *str1, *str2;
    str1 = "AE1156A6";
    ULONG ul = strtoul(str1, &str2, 16);