代码:
int StringToInt(char *hex) { return CharToInt(hex[0]) * 16 + CharToInt(hex[1]); } int CharToInt(char hex) { if (hex>='0' && hex <='9') return hex - '0'; if (hex>='A' && hex <= 'F') return hex-'A'+10; if(hex>='a' && hex <= 'f') return hex-'a'+10; return -1; }