#include <iostream>
using namespace std;
#define byte unsigned char
byte hex2byte(char hexstr[]);
int main()
{
char hex[3] = "67";
cout << int(hex2byte(hex));
}
byte hex2byte(char hexstr[])
{
byte h = hexstr[0];
byte l = hexstr[1];
if (isalpha(h))
h = h - 'a' + 10;
else
h = h - '0';
if (isalpha(l))
l = l - 'a' + 10;
else
l = l - '0';
return h * 16 + l;
}
参与评论
您还未登录,请先
登录
后发表或查看评论
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交