HP C/iX Library Reference Manual (30026-90004)
318 Chapter5
HP C/iX Library Function Descriptions
sprintf
2. Zero or more flags, which affect the way a value is written (see below).
3. An optional decimal digit string which specifies a minimum field width.
4. An optional
precision
consisting of a dot (.) followed by a decimal digit string.
5. An optional l, h, or L indicating that the argument is of an alternate type. When used
in conjunction with an integer conversion character, an l or h indicates a long or short
integer argument, respectively. When used in conjunction with a floating-point
conversion character, an L indicates a long double argument.
6. A conversion character, which indicates the type of data to be converted and written.
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 written 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. No space
padding is performed. If the 0 and - flags 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 written. 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 no
field width
is 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.