kj501:
自己写了个程序试试,呵呵,只能转换int类型整数。
#include
int main()
{
int num = 23165;
int temp[8];
int i;
/* print number in decimal base */
printf("the decimal number is %d\n", num);
/* transform binary number to hexadecimal notation */
for (i=7; i>=0; i--) {
if ( (temp[i] = num & 0x0f) > 9)
temp[i] += ('A' - 10);
else
temp[i] += '0';
num = num >> 4;
}
/* print number in hexadecimal base */
printf("the hexadecimal number is ");
for (i=0; i<8; i++)
if ('0' != temp[i]) printf("%c",temp[i]);
printf("\n");
}
DoDo:#include
int main(){
char a[255] = "";
sprintf(a, "hex(16)=%X", 16);
return 0;
}