can have the form %m.pX or %-m.pX where
± is the right or left justification
respectively m := minimum field width, no digits will
necessarily be lost if gone over. X := The conversion
specifier.
If X is a d then p indicates
the minimum number of digits to display. e - scientific
notation f - floating point in fixed decimal notation
g - either scientific notation or fixed decimal depending
on the number’s size. Useful when the size of the number cannot be
predicted.
printf("%f",d) for a double (same as a float) can use %e
or %g printf("%Lf",d) for a long double, can use %Le or
%Lg
printf is related to fprintf ( printf is fprintf but it always goes to stdout).
From the specification
converting them, if applicable, according to the corresponding conversion specifier, and
then writing the result to the output stream.
4
Each conversion specification is introduced by the character %. After the %, the following
appear in sequence:
— Zero or more flags (in any order) that modify the meaning of the conversion
specification.
— An optional minimum field width. If the converted value has fewer characters than the
field width, it is padded with spaces (by default) on the left (or right, if the left
adjustment flag, described later, has been given) to the field width. The field width
takes the form of an asterisk * (described later) or a nonnegative decimal integer.241)
— An optional precision that gives the minimum number of digits to appear for the d, i,
o, u, x, and X conversions, the number of digits to appear after the decimal-point
character for a, A, e, E, f, and F conversions, the maximum number of significant
digits for the g and G conversions, or the maximum number of bytes to be written for
s conversions. The precision takes the form of a period (.) followed either by an
asterisk * (described later) or by an optional decimal integer; if only the period is
specified, the precision is taken as zero. If a precision appears with any other
conversion specifier, the behavior is undefined.
— An optional length modifier that specifies the size of the argument.
— A conversion specifier character that specifies the type of conversion to be applied.
5
As noted above, a field width, or precision, or both, may be indicated by an asterisk. In
this case, an int argument supplies the field width or precision. The arguments
specifying field width, or precision, or both, shall appear (in that order) before the
argument (if any) to be converted. A negative field width argument is taken as a - flag
followed by a positive field width. A negative precision argument is taken as if the
precision were omitted.