一 赋值
int dex = 100;// 默认十进制 int oct = 0144;// 八进制,以0開始 int hex = 0x64;// 十六进制,以0x開始
二 输出
void show(int x) { printf("dec = %d; octal = %o; hex = %x ",x,x,x); printf("dec = %d; octal = %#o; hex = %#x ",x,x,x); }
比如:
int num = 100; show(num);
输出结果:
dec = 100; octal = 144; hex = 64
dec = 100; octal = 0144; hex = 0x64