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]...);
stream
format
argument
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.
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.
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) |
intime/rt/include/stdio.h intime/rt/include/wchar.h intime/rt/include/tchar.h |
stdio.h wchar.h tchar.h |
clib.lib |