Reads formatted text from a character string.
#include <stdarg.h> #include <stdio.h> int vsscanf(const char * s, const char * format, va_list arg);
s
A pointer to a character string from which to read formatted text.
format
A format string.
arg
An argument list.
The vsscantf() function works identically to the sscanf() function. Instead of the variable list of arguments that can be passed to sscanf(), vsscanf() accepts its arguments in the array arg of type va_list, w hich must have been initialized by the va_start() macro from the stdarg.h h eader file. The vfscanf() does not invoke the va_end macro.
vfscanf() returns the number of items assigned, which can be fewer than provided for in the case of an early matching failure. If an input failure occurs before any conversion, vfscanf() returns EOF.
This facility may not be available on configurations of the EWL that run on platforms without file systems.
#include <stdarg.h> #include <stdio.h> int ssc(char *, char *, ...); int main(void) { static char in[] = "figs cat pear 394 road 16!"; char s1[20], s2[20], s3[20]; int i; // Get the words figs, cat, road, // and the integer 16 // from in and store them in s1, s2, s3, and i, // respectively. ssc(in, "%s %s pear 394 %s %d!", s1, s2, s3, &i); printf("%s %s %s %d\n", s1, s2, s3, i); return 0; } // ssc() scans a character string and inputs // a variable number of arguments using // the vsscanf() function int ssc(char * s, char *format, ...) { va_list args; int retval; va_start(args, format); // prepare the arguments retval = vsscanf(s, format, args); va_end(args); // clean the stack return retval; } Output: figs cat road 16