fscanf

Scans input from a stream under format control

Local Servers:blocking
Remote Servers:blocking
Classification:ANSI
Platform:NLM
Service:Stream I/O

Syntax

  #include <stdio.h>  
   
  int fscanf  (  
     FILE         *fp,   
     const char   *format,   
     ... );
  

Parameters

fp
(IN) Points to the file.
format
(IN) Points to the format control string.

Return Values

The fscanf function returns EOF when the scanning is terminated by reaching the end of the input stream. Otherwise, it returns the number of input arguments for which values were successfully scanned and stored. If a file input error occurs, errno is set.

Remarks

The fscanf function scans input from the file designated by fp under control of the argument format. Following the format string is a list of addresses to receive values. The format string is described under the description of the scanf function.

See Also

scanf, sscanf

fscanf Example

To scan a date in the form "Saturday April 18 1991":

  #include <stdio.h> 
    
  main ()  
  {  
     int    day, year;  
     char   weekday[10], month[12];  
     FILE   *in_data;  
     in_data = fopen ("mydates.dat", "r");  
     fscanf (in data, "%s %s %d %d", weekday, month, &day, &year);  
  }