fscanf -- Read Data from a Stream

Format

#include <stdio.h>
int fscanf (FILE *stream, const char *format-string, argument-list);

Language Level: ANSI, POSIX, XPG4, Extension
fscanf reads data from the current position of the specified stream into the locations given by the entries in argument-list, if any. Each entry in argument-list must be a pointer to a variable with a type that corresponds to a type specifier in format-string.

The format-string controls the interpretation of the input fields and has the same form and function as the format-string argument for the scanf function.

In both OS/2 and Windows, in extended mode, the fscanf function also reads in the strings "INFINITY", "INF", and "NAN" (in upper or lowercase) and converts them to the corresponding floating-point value. The sign of the value is determined by the format specification.

Return Value
fscanf returns the number of fields that it successfully converted and assigned. The return value does not include fields that fscanf read but did not assign.

The return value is EOF if an input failure occurs before any conversion, or the number of input items assigned if successful.

Example



_cscanf -- Read Data from Keyboard
fprintf -- Write Formatted Data to a Stream
scanf -- Read Data
sscanf -- Read Data from Buffer
<stdio.h>