%d十進(jìn)制數(shù)厦取,%o八進(jìn)制數(shù)潮太,%x十六進(jìn)制數(shù)。
如果要在八進(jìn)制和十六進(jìn)制前顯示0和0x前綴,要分別在轉(zhuǎn)換說(shuō)明中加入#铡买;
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
int x=555;
printf("dec=%d,octal=%o;hex=%x\n",x,x,x);
printf("dec=%d,octal=%#o;hex=%#x\n",x,x,x);
return 0;
}
捕獲.PNG