// dec 10进制数
//base 转换基数
//strtrd 输出
void ConvertDec(int dec, int base,char*strtrd)
{
int t;
int p=0;
int idr;
while (dec !=0)
{
idr=dec%base;
if (idr>10)
{
strtrd[p++] =idr-10+65;
}
else
{
strtrd[p++] =idr+48;
}
dec /=base;
}
for (int i=0;i<p/2;i++)
{
t =strtrd[i];
strtrd[i]=strtrd[p-i-1];
strtrd[p-i-1] =t;
}
strtrd[p]='\0';
}
char text[20] ={0};
ConvertDec(255,16,text);
printf("%s\n",text);