你好!!
把你的代码发来看看!!
#include
#include
void main()
{
char string[81];
int i,num=0 ,word=0;
char c;
gets(string);
for(i=0;(c=string[i])!='\0';i++)
if(isspace(c)) //使用库函数
word=0;
else if(word ==0)
{
word=1;
num++;
}
printf("there are %d words in the line.\n",num);
}
测试:
kdjf dkf dkf
there are 3 words in the line.
Press any key to continue
string好像不能用做名称使用的吧
直接用string类型不就好了