C examples for stdio.h:vsscanf
function
<cstdio> <stdio.h>
Read formatted data from string into variable argument list
int vsscanf ( const char * s, const char * format, va_list arg );
Parameter | Description |
---|---|
s | source data. |
format | a format string. |
arg | a variable arguments list. |
On success, the function returns the number of items filled.
#include <stdio.h> #include <stdarg.h> void GetMatches ( const char * str, const char * format, ... ) { va_list args;//w w w . ja va 2 s. com va_start (args, format); vsscanf (str, format, args); va_end (args); } int main () { int val; char buf[100]; GetMatches ( "99 this is a test", " %d %s ", &val, buf); printf ("%s\n %d\n", buf, val); return 0; }