/请编写函数fun,该函数的功能是:统一一含字符串中单词的个数,作为函数值返回。一行字符串在主函数中输入,
规定所有单词由小写字母组成,单词之间由若干个空格格开,一行的开始没有空格。/
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#define N 200
int fun(char *buff)
{
int i=0,count=0;;
while (buff[i]!='\0')
{
if(buff[i]!=' ')
{
count++;
}
i++;
}
return count-1;
}
int main(void)
{
char buff[100];
printf("please enter A line consists of lowercase characters and Spaces\n");
fgets(buff,sizeof(buff),stdin);
int num=fun(buff);
printf("%d\n",num);
return 0;
}
标签:函数,int,单词,fun,字符串,buff
From: https://www.cnblogs.com/yesiming/p/18280745