HP C/iX Library Reference Manual (30026-90004)
Chapter 5 161
HP C/iX Library Function Descriptions
fprintf
fprintf
Writes data in formatted form to an open stream.
Syntax
#include <stdio.h>
int fprintf (FILE *
stream
, const char *
format
[,item [,item]...]
);
Parameters
stream
A pointer to an open stream where data is to be written.
format
A pointer to a character string defining the format of the data to be written
(or the character string itself enclosed in double quotes).
item
,… Each
item
is a variable or expression specifying the data to write.
Return Values
≥0 The number of characters written.
<0 An error occurred.
Description
The fprintf function enables you to output data in formatted form to an open stream. In
the fprintf function,
string
is a pointer to an open stream, and
format
is a pointer to a
character string (or the character string itself enclosed in double quotes) that specifies the
format and content of the data to be written. Each
item
is a variable or expression
specifying the data to write.
The fprintf format is similar to the printf function. It is made up of conversion
specifications and literal characters. Literal characters are all characters that are not part
of a conversion specification. Literal characters are written to the open stream exactly as
they appear in the format.
Conversion Specifications
The following list shows the different components of a conversion specification in their
correct sequence:
1. A percent sign (%), which signals the beginning of a conversion specification; to output
a literal percent sign, you must type two percent signs (%%).
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.