sscanf

Scans input from a character string under format control

Local Servers:blocking
Remote Servers:N/A
Classification:ANSI
Service:String Manipulation

Syntax

  #include <stdio.h>  
   
  int sscanf  (  
     const char   *in_string,   
     const char   *format,   
     ... );
  

Parameters

in_string
(IN) Points to a character string to scan.
format
(IN) Points to the format control string.

Return Values

The sscanf function returns EOF when 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.

Remarks

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.

See Also

fscanf, scanf (Single and Intra-File Services), vsscanf

Example

To scan the date in the form "Friday August 14 1991":

  #include <stdio.h>  
  main ()  
  {  
     int     day, year;  
     char    weekday[20], month[20];  
     sscanf ("Friday August 0014 1991", "%s %s %d  %d",  
        &weekday, &month, &day, &year);  
     printf ("%s %s %d %d\n", weekday, month, day, year);  
  }
  

produces the following:

  Friday August 14 1991