HP C/iX Library Reference Manual (30026-90004)
272 Chapter5
HP C/iX Library Function Descriptions
printf
6. A conversion character, which indicates the type of data to be converted and printed.
A one-to-one correlation must exist between each specification encountered and each item
in the item list.
The available
flags
are:
- Causes the data to be left-justified within its output field. Normally, the
data is right-justified.
+ Causes all signed data to begin with a sign (+ or -). Normally, only
negative values have signs.
blank Causes a blank to be inserted before a positive signed value. This is used
to line up positive and negative values in columnar data. Otherwise, the
first digit of a positive value is lined up with the negative sign of a
negative value. If the blank and + flags both appear, the blank flag is
ignored.
# Causes the data to be printed in an alternate form. Refer to the
descriptions of the conversion characters below for details concerning the
effects of this flag.
0 For d, i, o, u, x, X, e, E, f, g, and G conversions, leading zeros (following any
indication of sign or base) are used to pad to the field width. Space padding
is not performed. If the 0 and - flag s both appear, the 0 flag is ignored. The
0 flag is also ignored for d, i, o, u, x, and X conversions if a precision is
specified.
A
field width
, if specified, determines the minimum number of spaces allocated to the
output field for the particular piece of data being printed. If the data happens to be smaller
than the field width, the data is blank-padded on the left (or on the right, if the - flag is
specified) to fill the field. If the data is larger than the
field width
, the
field
width
is simply expanded to accommodate the data. An insufficient
field
width
never causes data to be truncated. If
field width
is not specified, the resulting
field is made just large enough to hold the data.
The
precision
is a value which means different things depending on the conversion
character specified. Refer to the descriptions of the conversion characters below for more
details.
NOTE
A
field width
or
precision
may be replaced by an asterisk (*). If so, the
next item in the item list is fetched, and its value is used as the
field width
or
precision
. The
item
fetched must be an integer.
Conversion Characters
Conversion characters specify the type of data to expect in the item list and cause the data
to be formatted and printed appropriately. The integer conversion characters are:
d, i An integer
item
is converted to signed decimal. The
precision
, if given,
specifies the minimum number of digits to appear. If the value has fewer
digits than that specified by the
precision
, the value is expanded with