输入输出 scanf和printf
转换说明符
printf修饰符
printf标识符
- #include<stdio.h>
- int main(void){
- const float f = 3852.99;
- printf("*%3.1f*\n",f);//四舍五入
- printf("*%+4.2f*\n",f);//添加符号标识
- printf("*%010.2f*\n",f);//添加前导零
- int n = 42;
- printf("*% d*\n",n);//正数产生空格
- printf("*% d*\n",-n);//负数产生符号
- printf("*%05.3d*\n",n);//整型精度表示显示的最少位数,忽略前导0
- char s[] = "Hello world!";
- printf("*%20.5s*\n",s);//字符串类型的精度表示现实的最大字符数
- getchar();
- return 0;
- }
转载于:https://blog.51cto.com/fanaticssk/823521