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
include <stdio.h>
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);
What the hell are these whiles? Shouldn’t they be ifs?
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
include <stdio.h>
int main()
{
}
What the hell are you doing playing f1? Shouldn’t the output be num
Why not use regular expressions? ?
Good comments
Are you counting letters or words?