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.
1st Parameter
Pointer to the null-terminated wide-character string to be read and parsed.
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
Pointer to a null-terminated wide-character string specifying the format to be matched. It can include format specifiers like `%d`, `%ls`, etc.
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
Pointers to variables where the parsed values will be stored. Each pointer corresponds to a format specifier in the `format` string.
Read more about parameters of swscanf in parameters section
The swscanffunction in C language Reads formatted input from a wide character string.
The swscanf function is the wide-character equivalent of sscanf. It reads formatted input from a wide string, interprets it according to the format string, and stores the results in the locations given by the additional arguments. This function is particularly useful for parsing wide character strings in internationalized applications.
The swscanffunction takes 3
parameters:
•
const wchar_t * `ws`: Pointer to the null-terminated wide-character string to be read and parsed.
•
const wchar_t * `format`: Pointer to a null-terminated wide-character string specifying the format to be matched. It can include format specifiers like `%d`, `%ls`, etc.
•
... `args`: Pointers to variables where the parsed values will be stored. Each pointer corresponds to a format specifier in the `format` string.
Reads formatted input from the wide-character string `ws` based on the format string `format` and stores the extracted values in the provided variables. Returns the number of input items successfully matched and assigned, or `EOF` if an error occurs or the end of the string is reached before any matches.
The swscanf function return value :
Returns the number of input items successfully matched and assigned
Returns EOF if an error occurred before any conversion
Output
This example demonstrates basic usage of swscanf to parse a wide string containing a name, age, and height.