C言語8進数と16進数

445 ワード

1賦の値.
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