user-0 提问: 不是说如果省略0标志，则会用空白补齐位数
为啥%.4d和%04d 显示出来都是0123?

回复:
user: user-1
content: 治好了我多年的颈椎病

user: user-2
content: 扔到百度咯 精密度规范 格式规范的第三个可选字段是精度规范。它指定一个非负的十进制整数，前面是句点（.），它指定要打印的字符数、小数位数或有效位数（见表R.5）。与宽度规范不同，精度规范可能导致输出值截断或浮点值舍入。如果精度指定为0且要转换的值为0，则结果不输出字符，如下所示：  printf（“%.0d”，0）；/*不输出字符*/  如果精度规范是星号（*），则参数列表中的int参数将提供该值。精度参数必须在参数列表中格式化的值之前。  如表R.5所示，当精度被省略时，类型决定精度的解释和默认值。  表R.5精度值如何影响类型  类型表示默认值 c，c精度没有影响。字符已打印。 d，i，u，o，x，x精度指定要打印的最小位数。如果参数中的位数小于精度，则输出值在左侧用零填充。当位数超过精度时，不会截断该值。默认精度为1。 e，e精度指定小数点后要打印的位数。最后打印的数字是四舍五入的。默认精度为6；如果精度为0或句点（.）后面没有数字，则不打印小数点。 f精度值指定小数点后的位数。如果出现小数点，则至少有一个数字出现在它之前。该值四舍五入到适当的位数。默认精度为6；如果精度为0，或者如果句点（.）后面没有数字，则不打印小数点。 g，g精度指定打印的最大有效位数。将打印六个有效数字，并截断任何尾随零。 s，s精度指定要打印的最大字符数。不打印超过精度的字符。打印字符，直到遇到空字符。   如果与浮点说明符对应的参数是无限、不定或NaN，则printf将提供以下输出。  价值产出 +无穷大1.内指 –无穷大–1.内数位 不定（与安静的NaN相同）数字。 非随机数

user: user-0
content: 引用 1 楼 赵4老师的回复:Precision Specification The third optional field of the format specification is the precision specification. It specifies a nonnegative decimal integer, preceded by a period (.), which specifies the number of characters to be printed, the number of decimal places, or the number of significant digits (see Table R.5). Unlike the width specification, the precision specification can cause either truncation of the output value or rounding of a floating-point value. If precision is specified as 0 and the value to be converted is 0, the result is no characters output, as shown below:  printf( "%.0d", 0 );      /* No characters output */  If the precision specification is an asterisk (*), an int argument from the argument list supplies the value. The precision argument must precede the value being formatted in the argument list.  The type determines the interpretation of precision and the default when precision is omitted, as shown in Table R.5.  Table R.5   How Precision Values Affect Type  Type Meaning Default  c, C The precision has no effect. Character is printed.  d, i, u, o, x, X The precision specifies the minimum number of digits to be printed. If the number of digits in the argument is less than precision, the output value is padded on the left with zeros. The value is not truncated when the number of digits exceeds precision. Default precision is 1.  e, E The precision specifies the number of digits to be printed after the decimal point. The last printed digit is rounded. Default precision is 6; if precision is 0 or the period (.) appears without a number following it, no decimal point is printed.   f  The precision value specifies the number of digits after the decimal point. If a decimal point appears, at least one digit appears before it. The value is rounded to the appropriate number of digits.  Default precision is 6; if precision is 0, or if the period (.) appears without a number following it, no decimal point is printed.  g, G The precision specifies the maximum number of significant digits printed. Six significant digits are printed, with any trailing zeros truncated.  s, S The precision specifies the maximum number of characters to be printed. Characters in excess of precision are not printed. Characters are printed until a null character is encountered.    If the argument corresponding to a floating-point specifier is infinite, indefinite, or NaN, printf gives the following output.  Value Output  + infinity 1.#INFrandom-digits  – infinity –1.#INFrandom-digits  Indefinite (same as quiet NaN) digit.#INDrandom-digits  NAN  digit.#NANrandom-digits 谢谢!  但是我不太看得懂

user: user-3
content: Precision Specification The third optional field of the format specification is the precision specification. It specifies a nonnegative decimal integer, preceded by a period (.), which specifies the number of characters to be printed, the number of decimal places, or the number of significant digits (see Table R.5). Unlike the width specification, the precision specification can cause either truncation of the output value or rounding of a floating-point value. If precision is specified as 0 and the value to be converted is 0, the result is no characters output, as shown below:  printf( "%.0d", 0 );      /* No characters output */  If the precision specification is an asterisk (*), an int argument from the argument list supplies the value. The precision argument must precede the value being formatted in the argument list.  The type determines the interpretation of precision and the default when precision is omitted, as shown in Table R.5.  Table R.5   How Precision Values Affect Type  Type Meaning Default  c, C The precision has no effect. Character is printed.  d, i, u, o, x, X The precision specifies the minimum number of digits to be printed. If the number of digits in the argument is less than precision, the output value is padded on the left with zeros. The value is not truncated when the number of digits exceeds precision. Default precision is 1.  e, E The precision specifies the number of digits to be printed after the decimal point. The last printed digit is rounded. Default precision is 6; if precision is 0 or the period (.) appears without a number following it, no decimal point is printed.   f  The precision value specifies the number of digits after the decimal point. If a decimal point appears, at least one digit appears before it. The value is rounded to the appropriate number of digits.  Default precision is 6; if precision is 0, or if the period (.) appears without a number following it, no decimal point is printed.  g, G The precision specifies the maximum number of significant digits printed. Six significant digits are printed, with any trailing zeros truncated.  s, S The precision specifies the maximum number of characters to be printed. Characters in excess of precision are not printed. Characters are printed until a null character is encountered.    If the argument corresponding to a floating-point specifier is infinite, indefinite, or NaN, printf gives the following output.  Value Output  + infinity 1.#INFrandom-digits  – infinity –1.#INFrandom-digits  Indefinite (same as quiet NaN) digit.#INDrandom-digits  NAN  digit.#NANrandom-digits