Pointer to the null-terminated string to be read and matched against the format string.
2nd Parameter Type : const char *
Pointer to read-only string
2nd Parameter
Pointer to a null-terminated string specifying the format to interpret the input. It may include format specifiers like `%d`, `%s`, etc.
3rd Parameter Type : va_list
A data type used to hold information about variable arguments passed to a variadic function. It is initialized with `va_start`, used with `va_arg`, and cleaned up with `va_end`.
3rd Parameter
A `va_list` object containing pointers to variables where the parsed input values will be stored. The `va_list` must be initialized with `va_start`.
Read more about parameters of vsscanf in parameters section
The vsscanffunction in C language Reads formatted data from a string using a va_list.
vsscanf is similar to sscanf, but instead of taking a variable number of arguments, it takes a va_list that has been initialized by va_start. This function reads formatted data from a string and stores the results in the locations pointed to by the elements in the va_list.
The vsscanffunction takes 3
parameters:
•
const char * `str`: Pointer to the null-terminated string to be read and matched against the format string.
•
const char * `format`: Pointer to a null-terminated string specifying the format to interpret the input. It may include format specifiers like `%d`, `%s`, etc.
•
va_list `args`: A `va_list` object containing pointers to variables where the parsed input values will be stored. The `va_list` must be initialized with `va_start`.
Reads input from the string `str` and matches it against the format string `format`. The extracted values are stored in the locations specified by the `va_list` object `args`. Returns the number of successfully matched and assigned input items, or `EOF` if an error occurs or the end of the string is reached before any matches.
The vsscanf 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 using vsscanf in a custom function to parse a string containing different types of data.