uint32_t HexStr2Int(CString str) { uint32_t nRet = 0; int nStart = 0; if (str.Left(2).CompareNoCase("0x") == 0) nStart = 2; for (int i = nStart; i < str.GetLength(); i++) { if (str[i] >= '0' && str[i] <= '9') nRet = nRet * 16 + str[i] - '0'; else if (str[i] >= 'A' && str[i] <= 'F') nRet = nRet * 16 + str[i] - 'A' + 10; else if (str[i] >= 'a' && str[i] <= 'f') nRet = nRet * 16 + str[i] - 'a' + 10; else { AfxMessageBox("Invalid Hexadecimal Format!", MB_OK); return -1; } } return nRet;
十六进制字符串转uint
猜你喜欢
转载自www.cnblogs.com/Zoya-/p/12550241.html
今日推荐
周排行