首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

c语言新手 一个简单有关问题

2012-10-14 
c语言新手求助 一个简单问题#include stdio.h#define IN 1#define OUT 0void main(){int c,nl,nw,nc,s

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

热点排行