follow my heart...
分类: C/C++
2006-06-08 14:50:34
gets(string);
for (i = 0; (c = string[i]) != '\0'; i++)
{
if (c == ' ')
word = 0;
else
if (word == 0)
{
word = 1;
num++;
}
}
printf("\nThere are %d words int the line.\n", num);
return 0;
}
运行结果(VC):
================================================
I am a boy.↙
There are 4 words int the line.
================================================