1 #include2 3 int main(void) 4 { 5 int a = 99; 6 float b = 9.9; 7 char c[] = "hello"; 8 9 printf("*%010d*\n", a);10 printf("*%10.3d*\n", a);11 printf("*%-10.3d*\n", a);12 printf("*%010.3d*\n", a);13 printf("*%-010.3d*\n", a);14 printf("------------\n");15 printf("*%010f*\n", b);16 printf("*%10.3f*\n", b);17 printf("*%-10.3f*\n", b);18 printf("*%010.3f*\n", b);19 printf("*%-010.3f*\n", b);20 printf("------------\n");21 printf("*%010s*\n", c);22 printf("*%10.3s*\n", c);23 printf("*%-10.3s*\n", c);24 printf("*%010.3s*\n", c);25 printf("*%-010.3s*\n", c);26 27 return 0;28 }
如果0标志和精度说明符在字符串和整数输出中同时出现,那么0标志就会被忽略,但浮点数输出仍会显示