1. 十六进制字符串转数字
std::string str = "0xef"; char c = (char)strtol(str.c_str(), NULL, 16); printf("0x%02x ", (unsigned char)c);结果
2.十六进制数字转字符串
char c = 0x0e; char ch[10] = {0}; sprintf(ch, "0x%02x", (unsigned char)c);结果
3. 十六进制输出字符
char c = 0xa8; printf("0x%02x ", (unsigned char)c);结果
此为标准格式:02保证输出长度为两位、不足补0;(unsigned char)