回复 2楼 韶志
(c = getchar()) != EOF这个东西的作用是什么?另外
#include <stdio.h>
#define IN
1
/* inside a word */
#define OUT
0
/* outside a word */
/* count lines, words, and characters in input */
main()
{
int c, nl, nw, nc, state;
state = OUT;
nl = nw = nc = 0;
while ((c = getchar()) != EOF) {
++nc;
if (c == '\n')
++nl;
if (c == ' ' || c == '\n' || c == '\t')
state = OUT;
else if (state == OUT) {
state = IN;
++nw;
}
}
printf("%d %d %d\n", nl, nw, nc);
}这个程序是用来统计单词数,行数以及字符数的,但是运行时怎么出不来结果啊。。。求指导