
Reads formatted data from a stream. These versions of fscanf, _fscanf_l, fwscanf, _fwscanf_l have security enhancements, as described in Security Features in the CRT.
int fscanf_s(
FILE *stream,
const char *format [,
argument ]...
);
int _fscanf_s_l(
FILE *stream,
const char *format,
locale_t locale [,
argument ]...
);
int fwscanf_s(
FILE *stream,
const wchar_t *format [,
argument ]...
);
int _fwscanf_s_l(
FILE *stream,
const wchar_t *format,
locale_t locale [,
argument ]...
);
stream
Pointer to FILE structure.
format
Format-control string.

argument
Optional arguments.
locale
The locale to use.
Each of these functions returns the number of fields that are 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. If an error occurs, or if the end of the file stream is reached before the first conversion, the return value is EOF for fscanf_s and fwscanf_s.
These functions validate their parameters. If stream is an invalid file pointer, or format is a null pointer, these functions invoke the invalid parameter handler, as described in Parameter Validation. If execution is allowed to continue, these functions return EOF and set errno to EINVAL.

The fscanf_s function reads data from the current position of stream into the locations that are given by argument (if any). Each argument must be a pointer to a variable of a type that corresponds to a type specifier in format. format controls the interpretation of the input fields and has the same form and function as the format argument for scanf_s; see Format Specification Fields: scanf and wscanf Functions for a description of format. fwscanf_s is a wide-character version of fscanf_s; the format argument to fwscanf_s is a wide-character string. These functions behave identically if the stream is opened in ANSI mode. fscanf_s doesnt currently support input from a UNICODE stream.
本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/jisuanjixue/article-94874-1.html
是1888年