INtime SDK Help
fscanf, fwscanf, fscanf_s, fwscanf_s

Reads and formats character data from the current position of a stream into the specified locations.

#include <stdio.h>

int fscanf(FILE *stream, const char *format[, argument]...);
int fscanf_s(FILE *stream, const char *format[, argument]...);

#include <wchar.h>

int fwscanf(FILE *stream, const wchar_t *format[, argument]...);
int fwscanf_s(FILE *stream, const wchar_t *format[, argument]...);


Pointer to FILE structure.
Null-terminated format-control string, which controls the interpretation of the input fields.
Optional argument(s) specify location. Each argument must be a pointer to a variable with a type that corresponds to a type specifier in format. The results are unpredictable if there are not enough arguments for the format specification. If there are too many arguments, the extra arguments are evaluated but ignored.


fscanf reads all characters in stream up to the first whitespace character (space, tab, or newline), or the first character that cannot be converted according to format.

format is as described in scanf.

fwscanf is the wide-character version of fscanf.

fscanf_s and fwscanf_s are the secure versions of fscanf and fwscanf, with parameter checking.

Return Values

Returns the number of fields successfully converted and assigned; the return value does not include fields that were read but not assigned. A return value of 0 indicates that no fields were assigned. The return value is EOF for an error, or if the end-of-file character or the end-of-string character is encountered in the first attempt to read a character. If format is a NULL pointer, scanf_s and wscanf_s return EOF and set errno to EINVAL.

Generic Text Routines

tchar.h routine _UNICODE not defined _UNICODE defined
_ftscanf fscanf fwscanf
_ftscanf_s fscanf_s fwscanf_s


Versions Defined in Include Link to
INtime 3.0
INtime 6.0 (for wide-character and generic text versions)
See Also