Pointer to the file stream from which input is to be read
2nd Parameter Type : const wchar_t *
A pointer to a read-only wide-character string, where each character is of type `wchar_t`. Used for representing text in wide-character encoding to support extended character sets, such as Unicode. The string is null-terminated, with the terminator being a `wchar_t` with value 0.
2nd Parameter
A null-terminated wide-character string specifying the input format, including conversion specifiers
3rd Parameter Type : ...
Represents a variable number of arguments in a function. Used in functions like `printf` or `fprintf` to accept additional parameters beyond those explicitly declared.
3rd Parameter
Variable number of pointers where the converted input values will be stored
Read more about parameters of fwscanf in parameters section
The fwscanffunction in C language Reads formatted wide character input from a stream.
The fwscanf function reads input from the stream pointed to by stream, under control of the wide string pointed to by format that specifies the admissible input sequences and how they are to be converted for assignment, using subsequent arguments as pointers to the objects to receive the converted input. It behaves similarly to fscanf but uses wide characters. A matching failure occurs if the input cannot be matched to the format string.
The fwscanffunction takes 3
parameters:
•
FILE * `stream`: Pointer to the file stream from which input is to be read
•
const wchar_t * `format`: A null-terminated wide-character string specifying the input format, including conversion specifiers
•
... `args`: Variable number of pointers where the converted input values will be stored
Reads formatted wide-character input from the specified file stream according to the `format` string and stores the results in the locations pointed to by the provided arguments. Returns the number of input items successfully matched and assigned, or `EOF` if an error occurs or the end-of-file is reached before any conversion.
The fwscanf function return value :
Returns the number of input items successfully matched and assigned
This can be fewer than provided for, or zero in the event of an early matching failure
EOF is returned if the end of input is reached before either the first successful conversion or a matching failure occurs
Output
This example demonstrates basic usage of fwscanf to read formatted wide character input from a file. It reads a name (wide string), age (integer), and height (float) from the file.