|
#include<stdio.h>
#include<ctype.h>
int found_next_word(void);
int main(void)
{
int word_count=0;
while (found_next_word() == 1)
++word_count;
printf("Number of words = %d\n\n", word_count);
getch();
return 0;
}
int found_next_word(void)
{
int c;
while (isspace(c=getchar()))
; /*skip white space*/
if (c != EOF){ /*found a word*/
while ((c = getchar()) != EOF && !isspace(c))
;
return 1;
}
return 0;
}
似乎无法读取回车
WIN TC2
[ 本帖最后由 iptton 于 2006-10-25 13:05 编辑 ] |
|