高洛峰2017-04-17 13:14:33
Young man, this code of yours has a lot of bugs. If there are two consecutive spaces, there will be an extra note. If there is no period, you will miss a word. Please add the code
int main()
{
char s[80] = {0};
char *p;
int num = 0;
unsigned char flag = 0;
gets(s);
p = s;
while(*p++)
{
if(( *p >= 'a' && *p <= 'z')||( *p >= 'A' && *p <= 'Z') )
{
flag = 1;
}
else if (flag == 1)
{
flag = 0;
num++;
}
}
printf("there are %d words\n",num);
}