HP C/iX Library Reference Manual (30026-90004)

178 Chapter5
HP C/iX Library Function Descriptions
fscanf
fscanf
Reads externally formatted data from an open stream.
Syntax
#include <stdio.h>
int fscanf (FILE *
stream
, const char *
format
[,item [,item]...]
);
Parameters
stream
A pointer to an open stream from which data is to be read.
format
A pointer to a character string defining the format of the data to be read
(or the character string itself enclosed in double quotes).
item
Each
item
is the address of a variable into which the data will be placed.
Refer below to descriptions of conversion specifications.
Return Values
0 The number of successfully matched and assigned input items.
EOF An error occurred on input (no input characters, or a matching error
occurred before any conversion).
Description
The fscanf function reads externally formatted data from an open stream, converts the
data to internal format, and stores the results in a group of arguments. The format
consists of white-space characters, conversion specifications, and literal characters.
This function behaves identically to the scanf function except that fscanf() reads data
from an open input stream instead of from stdin.
White-Space Characters
White-space characters (blanks, tabs, newlines, or form feeds) cause input to be read up to
the next non-white-space character.
Conversion Specifications
A conversion specification is a character sequence that tells fscanf() how to interpret the
data received at that point in the input.
In the format, a conversion specification is introduced by a percent sign (%), optionally
followed by an asterisk (*) (called the assignment suppression character), optionally
followed by an integer value (called the field width). The conversion specification is
terminated by a character specifying the type of data to expect; the terminating characters