void main()
{
int n=0x138c;
unsigned char k10[5];
k10[0]=n/10000 + 0x30;
k10[1]=n/1000 % 10+0x30;
k10[2]=n/100 % 10+0x30;
k10[3]=n/10 % 10+0x30;
k10[4]=n%10 + 0x30;
while(1);
}
//////////////////////////////////////////////////
編譯后的信息:
Build target 'Target 1'
compiling hex2dec.c...
linking...
Program Size: data=14.0 xdata=0 code=257
"hex2dec" - 0 Error(s), 0 Warning(s).
///////////////////////////////////////////////////
#include <reg52.h>
#include <stdio.h>
void main()
{
int k=0x138c;
unsigned char disbuf[5];
sprintf(disbuf,"%05d",k);
while(1);
}
//////////////////////////////////////////////////
編譯后的信息:
Build target 'Target 1'
compiling hex2dec.c...
linking...
Program Size: data=40.1 xdata=0 code=1087
"hex2dec" - 0 Error(s), 0 Warning(s).
////////////////////////////////////////////////// |