sscanf() ------ 获取字符串中的参数

可以从字符串中获取需要的参数,如下:

#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
", month, day, year, weekday );
    
   return(0);
}
March 25, 1989 = Saturday
原文地址:https://www.cnblogs.com/god-of-death/p/14255793.html