将两个字符转化成一个十六进制数
注:以下代码中默认 UINT8 a=‘3’,UINT8 b=‘F’,就不写函数调用了;
#include<stdio.h>
typedef unsigned char UINT8;
typedef unsigned short UINT16;
UINT8 transform(UINT8 a,UINT8 b)
{
UINT8 c;
if(a>='0' && a<='9')
{
a=a-'0';
}
else if(a>='A' && a<='F')
{
a=a-'A'+10;
}
else if(a>='a' && a<='f')
{
a=a-'a'+10;
}
if(b>='0' && b<='9')
{
b=b-'0';
}
else if(b>='A' && b<='F')
{
b=b-'A'+10;
}
else if(b>='a' && b<='f')
{
b=b-'a'+10;
}
return (a<<4)|b;
}