#include <stdio.h>
#include
<stdlib.h>
#include
<string.h>
#include
<unistd.h>
int main(int argc, char *argv[])
{
char buf[100];
char str[20] = "helloworld 100";

int num;

sscanf(str,
"%s %d",buf,&num);

printf(
"the buf:%s %d\n",buf,num);
return 0;
}

和scanf基本用法相同,不同点:

scanf是以标准输入为输入对象

sscanf是以字符串为输入对象

相关文章:

  • 2021-11-07
  • 2021-09-11
  • 2021-10-12
  • 2022-12-23
猜你喜欢
  • 2021-10-14
  • 2022-12-23
  • 2021-10-03
  • 2022-12-23
  • 2022-12-23
  • 2021-06-29
  • 2021-08-31
相关资源
相似解决方案