The minimum field width can be specified as a decimal-digit
string following any flag specifier, in which case the field
width is set to the specified number of columns. The field width
can also be specified as asterisk (*
) in
which case an additional argument of type int
is accessed to determine the field width.
For example, to print an integer x
in a field
width determined by the value of the int
variable w
, you would write the following D
statement:
printf("%*d", w, x);
The field width can also be specified with a
?
character to indicate that the field width
should be set based on the number of characters required to
format an address (in hexadecimal) in the data model of the
operating system kernel. The width is set to
8
, if the kernel is using the 32-bit data
model, or to 16
, if the kernel is using the
64-bit data model. The precision for the conversion can be
specified as a decimal digit string following a period
(.
), or by an asterisk (*
)
following a period. If an asterisk is used to specify the
precision, an additional argument of type int
before the conversion argument provides the precision. If both
width and precision are specified as asterisks, the order of
arguments to printf
for the conversion should
appear in the following order: width, precision, value.