[Previous]
[Contents]
[Next]

sscanf()

scan input from a character string

Synopsis:

#include <stdio.h>

int sscanf( const char *in_string,
            const char *format, ... );

Description:

The sscanf() function scans input from the character string in_string, under control of the argument format. Following the format string is the list of addresses of items to receive values.

The format string is described under the description of the scanf() function.

Returns:

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.

Examples:

#include <stdio.h>

/* Scan a date in the form "Saturday April 18 1987" */

void main()
  {
    int day, year;
    char weekday[20], month[20];

    sscanf( "Friday August 0014 1987",
      "%s %s %d  %d",
      weekday, month, &day, &year );
    printf( "%s %s %d %d\n",
      weekday, month, day, year );
  }

produces the following:

Friday August 14 1987

Classification:

ANSI

Safety:
Interrupt handler No
Signal handler No
Thread Yes

See also:

cscanf(), fscanf(), scanf(), vcscanf(), vfscanf(), vscanf(), vsscanf()


[Previous]
[Contents]
[Next]