int fprintf(FILE *stream, const char *format, ...),
will transform the output (arguments to fill in ...) and write it to stream. The format defined in format will be written, too. The function will return the number of written characters or a negative value on error.
format contains two kinds of objects
- normal characters for the output and
- information how to transform or format the arguments.
Format information must begin with % followed by values for the format followed by a character for the translation (to print % by itself use %%). Possible values for the format are:
- Flags
- -
The formatted argument will be printed on the left margin (default is the right margin in the argument field).
- +
Every number will be printed with a sign, e.g. +12 or -2.32.
- Blank
When the first character is not a sign, a blank will be inserted.
- 0
For numeric transformation the field width will be filled up with 0's on the left side.
-
#
Alternate output depending on the transformation for the argument
- For o the first number is a 0.
- For x or X 0x or 0X will be printed in front of the argument.
- For e, E, f or F the output has a decimal point.
- For g or G zeroes on the end of the argument are printed.
- A number for the minimal field width.
The transformed argument is printed in a field which is at least as big as the argument itself. With a number you can make the field width bigger. If the formatted argument is smaller, then the field width will be filled with zeroes or blanks.
- A point to separate the field width and the precision.
- A number for the precision.
Possible values for the transformation are in table 8.1 on page .