fscanf
Scans input from a stream under format control
#include <stdio.h> int fscanf ( FILE *fp, const char *format, ... );
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.
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.
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); }