Standard C++ Library Reference ISO/IEC (VERSION3)
one of the print conversion specifications described below.
A print function scans the format string once from beginning to end to determine what
conversions to perform. Every print function accepts a varying number of arguments, either
directly or under control of an argument of type va_list. Some print conversion
specifications in the format string use the next argument in the list. A print function uses each
successive argument no more than once. Trailing arguments can be left unused.
In the description that follows:
integer conversions are the conversion specifiers that end in d, i, o, u, x, or X●
floating-point conversions are the conversion specifiers that end in e, E, f, g, or G●
Print Functions
For the print functions, literal text or white space in a format string generates characters that
match the characters in the format string. A print conversion specification typically generates
characters by converting the next argument value to a corresponding text sequence. A print
conversion specification has the format:
Boldface indicates a feature added with C99.
Following the percent character (%) in the format string, you can write zero or more format
flags:
- -- to left-justify a conversion●
+ -- to generate a plus sign for signed values that are positive●
space -- to generate a space for signed values that have neither a plus nor a minus
sign
●
# -- to prefix 0 on an o conversion, to prefix 0x on an x conversion, to prefix 0X on an X
conversion, or to generate a decimal point and fraction digits that are otherwise
suppressed on a floating-point conversion
●
0 -- to pad a conversion with leading zeros after any sign or prefix, in the absence of a
minus (-) format flag or a specified precision
●
Following any format flags, you can write a field width that specifies the minimum number of
characters to generate for the conversion. Unless altered by a format flag, the default behavior is
to pad a short conversion on the left with space characters. If you write an asterisk (*) instead
of a decimal number for a field width, then a print function takes the value of the next argument