| ![[Previous]](../image-lib/prev.gif) | ![[Contents]](../image-lib/contents.gif) | ![[Index]](../image-lib/keyword_index.gif) | ![[Next]](../image-lib/next.gif) | 
Scan input from a string
#include <stdio.h>
#include <stdarg.h>
int vsscanf( const char* in_string,
             const char* format,
             va_list arg );
libc
The vsscanf() function scans input from the string designated by in_string, under control of the argument format. The format string is described under the description of the scanf() function.
The vsscanf() function is equivalent to the sscanf() function, with a variable argument list replaced with arg, which has been initialized using the va_start() macro.
EOF when the scanning is terminated by reaching the end of the input string. Otherwise, the number of input arguments for which values were successfully scanned and stored is returned.
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
void sfind( char* string, char* format, ... )
  {
    va_list arglist;
    va_start( arglist, format );
    vsscanf( string, format, arglist );
    va_end( arglist );
  }
int main( void )
  {
    int day, year;
    char weekday[10], month[12];
    sfind( "Monday June 28 1999",
        "%s %s %d %d",
        weekday, month, &day, &year );
    printf( "\n%s, %s %d, %d\n",
        weekday, month, day, year );
    return EXIT_SUCCESS;
  }
| Safety: | |
|---|---|
| Cancellation point | No | 
| Interrupt handler | Read the Caveats | 
| Signal handler | Read the Caveats | 
| Thread | Yes | 
It's safe to call vsscanf() in an interrupt handler or signal handler if the data isn't floating point.
fscanf(), scanf(), sscanf(), va_arg(), va_end(), va_start(), vfscanf()
| ![[Previous]](../image-lib/prev.gif) | ![[Contents]](../image-lib/contents.gif) | ![[Index]](../image-lib/keyword_index.gif) | ![[Next]](../image-lib/next.gif) |