sscanf()

description

C library function int sscanf (const char * str, const char * format, ...) is read from the input string format.

Examples

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

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

   strcpy( dtm, "Saturday March 25 1989" );
   sscanf( dtm, "%s %s %d  %d", weekday, month, &day, &year );

   printf("%s %d, %d = %s\n", month, day, year, weekday );
    
   return(0);
}

 

Guess you like

Origin www.cnblogs.com/xumaomao/p/11985567.html