printf的格式说明符
%c
打印单个ASCII 字符
printf("The character is %c\n",x)
输出: The character is A
%d
打印一个十进制数
printf("The boy is %d years old\n",y)
输出:The boy is 15 years old
%e
打印数字的e 记数法形式
printf("z is %e\n",z) 打印: z is 2.3e+0 1
%f
打印一个浮点数
printf("z is %f\n", 2.3 * 2)
输出: z is 4.600000
%o
打印数字的八进制
printf("y is %o\n",y)
输出:z is 17
%s
打印一个字符串
print("The name of the culprit is %s\n",$1)
输出:The name of the culprit is Bob Smith
%x 打印数字的十六进制值
printf("y is %x\n",y)
输出:x is f
浙公网安备 33010602011771号