printf()使用以下格式:

printf("format_string"[,var[,...]]);

printf()转换字符

转换字符 显示参数(变量的内容)
%c 单个字符
%d 带符号十进制整数(int)
%e E表示法中的有符号浮点值
%f 有符号浮点值(浮点数)
%g %e%f格式的有符号值,以较短者为准
%i 带符号十进制整数(int)
%o 无符号八进制(基数为8)整数(int)
%s 文字串
%u 无符号十进制整数(int)
%x 无符号十六进制(基数为16)整数(int)


#include <stdio.h>
#include <math.h>
int main()
{
   double lights;
   lights=pow(2,8);               /* figure 2 to the 8th power */
   printf("Milton, we need %0.f lights\n",lights);
   return(0);
}