Search

9/02/2006

hex, oct -> decimal -> hex, oct

int main()
{
char hex[100], oct[100];
long num = 32712;

puts(hex);
sprintf(hex, "%X", num);
puts(hex);
sprintf(oct, "%o", num);
puts(oct);

sscanf(hex, "%x", &num);
printf("%d\n", num);
sscanf(oct, "%o", &num);
printf("%d\n", num);
}

7fc8
7FC8
77710
32712
32712

沒有留言: