LINUX C例程1:sscanf的用法

#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是以字符串为输入对象

posted @ 2011-07-18 14:26  hnrainll  阅读(2224)  评论(0编辑  收藏  举报