填空题
下列给定程序中,函数fun的功能是:计算出形参s所指字符串中包含的单词个数,作为函数值返回。为便于统计,规定各单词之间用空格隔开。
例如,形参s所指的字符串为:This is a c language program.,函数的返回值为6。
请在程序的下划线处填入正确的内容,使程序得出正确的结果。
注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
inc fun(char *s)
{inc n=0,flag=0;
while(*s!="/0")
{if(*s!="&&flag==0){
/********found********/
1;flag=l;}
/********found********/
if(*s==")flag=
2;
/********found********/
3;
}
return n;
}
main()
{char str[81];int n;
printf("/nEnter a line text:/n");
gets(str);
n=fun(str);
printf("/nThere are%d words in this text./n/n",n);
}