#include <reg52.h>
#define uchar unsigned char
const unsigned char tab_char[16]= { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
htoa(char *str,uchar num) { uchar tmp;
tmp=num;
tmp=tmp&0xf0;
tmp>>=4;
*str=tab_char[tmp];
str++;
*str=tab_char[num&0x0f];
} 下面是我的测试方法,但是好像不对没有将单字节转成两个asc码 void main()
{
uchar m=0x35;
htoa(m,1);
}
|