Guardian C Library Calls Reference Manual

fscanf
3-62 128833Guardian TNS C Library Calls Reference Manual
Reference to Library Calls
stream
denotes a file opened for ANSI I/O.
format
points to a string that specifies how to convert the input text for assignment, using
subsequent arguments as pointers to the variables to receive the converted input.
This format string is described in the next subsection, “Usage Guidelines.
obj_ptr...
is a list of pointers to variables, specifying where the results of the conversions
defined in *format are to be stored.
Return Value
is the number of items for which fscanf found valid data, including all single-
character items in *format that were matched. If an error occurs, fscanf returns the
value EOF.
Usage Guidelines
The Format String
The fscanf function interprets the format string, *format, as a series of directives that
describe how to scan, convert, and store the input read from *stream. There are three
kinds of directives:
Conversion specifiers
Space characters (blanks, tabs, newlines, and so on)
Plain characters (nonspace characters that are not part of a conversion specifier)
Each conversion specifier requires input from the file, which is then converted and
stored in a specified variable.
One or more space characters in *format (blanks, horizontal tabs, newline, vertical
tabs, form feeds, and comments) causes one or more consecutive space characters in
the input to be skipped over. That is, the number of consecutive space characters in
*format does not have to match the number in the input at that point.
Other characters in *format–characters that are neither characters in conversion
specifiers nor space characters–must match current input, character by character, in
order for the input process to continue.