#include "windows.h"#include<cstdlib>//参考ASCII码表设计static int hex_tablehpdyj = {0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 1, 2, 3, 4, 5, 6,7, 8, 9, 0, 0, 0, 0, 0, 0,0, 10, 11, 12, 13, 14, 15, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 10,11, 12, 13, 14, 15 };int hex_to_decimal(char* hex_str)//简单strtol底层实现方法{ char ch; int iret = 0; while (ch = *hex_str++) { iret = (iret << 4) | hex_table[ch]; } return iret;}int main(){ int n = _countof(hex_table); int c = hex_to_decimal(const_cast<char*>("1E2E")); int a = strtol("1E2E",nullptr,16); return 0;}