C语言 实现将16进制数转成10进制数
int main(int argc, char *argv[])
{
hextoDec(0xffff);
return 0;
}
void hextoDec(int hex){
int sum=0,mul=1;
int i,r;
int count=0;
do{
r=hex%16;
for(i=0;i<count;i++)
mul*=16;
mul*=r;
sum+=mul;
mul=1;
count++;
}while(hex/=16);
printf("%d\n",sum);
}