1. 程式人生 > >C語言基礎:將整數格式化成其它進制輸出的代碼

C語言基礎:將整數格式化成其它進制輸出的代碼

基礎 輸出 oct %d 語言 int 資料 stdio.h main

如下的資料是關於C語言基礎:將整數格式化成其它進制輸出的代碼。

#include <stdio.h>
int main ()
 {
   int value = 255;

   printf("The decimal value %d in octal is %on",
        value, value);

   printf("The decimal value %d in hexadecimal is %xn", 
        value, value);

   printf("The decimal value %d in hexadecimal is %Xn", 
        value, value);

    return 1;
 }

gcc編譯運行結果

The decimal value 255 in octal is 377
The decimal value 255 in hexadecimal is ff
The decimal value 255 in hexadecimal is FF

C語言基礎:將整數格式化成其它進制輸出的代碼