刚开始学C,有很菜的问题
#include <stdio.h>
#define in 1
#define out 0
mian()
{
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;
}
}
orintf("%d %d %d\n", nl, nw, nc);
}
在 the c programming language 第二版中有一个例子
不知道是不是我的理解有问题,我怎么看不懂呢
是每打一个字符nl自加,还是没打一个单词才自加
state的作用在哪啊?