Guardian C Library Calls Reference Manual

Reference to Library Calls
Guardian TNS C Library Calls Reference Manual128833 3-51
fprintf
fprintf
The fprintf function writes formatted data to a file opened for ANSI I/O.
stream
denotes a file opened for ANSI I/O.
format
points to a string that specifies how to format the data given by expr.... This format
string is described under “Usage Guidelines.
expr...
is a list of expressions whose values fprintf formats using *format and then prints to
*stream.
Return Value
is the number of characters output if the operation is successful; otherwise, fprintf
returns a negative value.
Usage Guidelines
The Format String
The fprintf function interprets the format string, *format, as a series of literal
characters and conversion specifiers. fprintf outputs the literal characters as they
appear in the format string, and uses the conversion specifiers to format the values of
the expressions in expr.... The format of a conversion specifier is:
% [flags] [width] [.precision] [modifier] conv_code
The percent sign indicates the start of a conversion specifier. Here are the
components that follow it:
flags is a list of zero or more flags that alter or modify the formatting of a
converted value.
width is an optional decimal number that specifies the minimum width (in
characters) of the field containing the value. If the converted value is shorter
than the given field width, fprintf pads the value on the left (unless you use the
left-justify flag described later) to fill the field. fprintf pads with blanks unless
width begins with a zero, in which case fprintf pads with zeros.
#include <stdioh>
int fprintf(FILE *stream, const char *format, [expr...]);