c语言新手求助 一个简单问题
#include <stdio.h>
#define IN 1;
#define OUT 0;
void 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);
}
错误提示:
D:\c chengxu\getchar\getchar.cpp(18) : error C2143: syntax error : missing ')' before ';'
D:\c chengxu\getchar\getchar.cpp(18) : error C2059: syntax error : ')'
D:\c chengxu\getchar\getchar.cpp(18) : warning C4390: ';' : empty controlled statement found; is this the intent?
执行 cl.exe 时出错.
getchar.obj - 1 error(s), 0 warning(s)
} else if (state == OUT) {
把out 换成 0 就不报错了 不明白为什么??
[解决办法]
#define OUT 0;
后面多了一个;
应该是
#define OUT 0