99re热这里只有精品视频,7777色鬼xxxx欧美色妇,国产成人精品一区二三区在线观看,内射爽无广熟女亚洲,精品人妻av一区二区三区

printf

2018-11-11 15:48 更新

 原型:extern void printf(const char *format,...);
 
 用法:#include <stdio.h>
 
 功能:格式化字符串輸出
 
 說明:format指定輸出格式,后面跟要輸出的變量
       目前printf支持以下格式:
         %c        單個(gè)字符
         %d        十進(jìn)制整數(shù)
         %f        十進(jìn)制浮點(diǎn)數(shù)
         %o        八進(jìn)制數(shù)
         %s        字符串
         %u        無符號十進(jìn)制數(shù)
         %x        十六進(jìn)制數(shù)
         %%        輸出百分號%
       一個(gè)格式說明可以帶有幾個(gè)修飾符,用來指定顯示寬度,小數(shù)尾書及左對齊等:
         -         左對齊
         +         在一個(gè)帶符號數(shù)前加"+"或"-"號
         0         域?qū)捰们皩?dǎo)零來填充,而不是用空白符
       域?qū)捠且粋€(gè)整數(shù),設(shè)置了打印一個(gè)格式化字符串的最小域。精度使用小數(shù)點(diǎn)后加數(shù)字表示的,
       給出每個(gè)轉(zhuǎn)換說明符所要輸出的字符個(gè)數(shù)。  

注意:帶修飾符的顯示可能不正常

         
 舉例:


     // printf.c
     
     #include <stdio.h>
     #include <system.h>
     main()
     {
       int i;
       char *str="GGV";
       
       clrscr();
       
       textmode(0x00);
       printf("Printf Demo-%%c");
       printf("--------------");
       printf("%c-%c-%c-%c\n",'D','e','m','o');
       printf("%2c-%2c-%2c-%2c\n",'D','e','m','o');
       printf("%02c-%02c-%02c-%02c\n",'D','e','m','o');
       printf("%-2c-%-2c-%-2c-%-2c\n",'D','e','m','o');
       
       getchar();
       clrscr();
       textmode(0x00);            // not nessary
       i=7412;
       printf("Printf Demo-%%d");
       printf("--------------");        
       printf("%d\n",i);
       printf("%14d",i);
       printf("%+10d\n",i);       // output format not correct(bug)
       printf("%-10d\n",i);
       
       getchar();
       clrscr();
       printf("Printf - d,o,x");
       printf("--------------");        
       printf("%d\n",i);
       printf("%o\n",i);         // %o and %x not implemented
       printf("%x\n",i);
       
       getchar();
       clrscr();
       printf("Printf Demo-%%s");
       printf("--------------");
       printf("   %s\n","Demo End");
       printf("    %s\n","Thanx");
       printf("    %s\n  %s","Golden","Global View");
       
       getchar();
       return 0;
     }      


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號