sscanf():从字符串读取格式化输入

描述

C 库函数 int sscanf(const char *str, const char *format, ...) 从字符串读取格式化输入。

实例

#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);
}

 

posted @ 2019-12-04 21:00  xd_xumaomao  阅读(605)  评论(0编辑  收藏  举报