printf的格式说明符

%c   
打印单个ASCII 字符
printf("The character is %c
",x)
输出: The character is A

%d
打印一个十进制数
printf("The boy is %d years old
",y)
输出:The boy is 15 years old

%e	
打印数字的e 记数法形式
printf("z is %e
",z) 打印: z is 2.3e+0 1

%f	
打印一个浮点数
printf("z is %f
", 2.3 * 2)
输出: z is 4.600000


%o	
打印数字的八进制
printf("y is %o
",y)
输出:z is 17

%s	
打印一个字符串
print("The name of the culprit is %s
",$1)
输出:The name of the culprit is Bob Smith


%x	打印数字的十六进制值
printf("y is %x
",y)
输出:x is f

  

原文地址:https://www.cnblogs.com/luyuheng/p/11690505.html