sscanf
Scans input from a character string under format control
#include <stdio.h> int sscanf ( const char *in_string, const char *format, ... );
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.
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.
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