计算单词数、行数、字符数!求解
程序代码:
#include<stdio.h> #define IN 1 /*inside a word*/ #define OUT 0 /*outside a word*/ main() { int c,word_amount,word_row,character,state; state=OUT; word_amount=word_row=character=0; while((c=getchar())!=EOF) { ++character; if(c='\n') ++word_row; if(c=='\n'||c=='\t'||c==' ') state=OUT; else if(state=OUT) state=IN; ++word_amount; } printf("%d,%d,%d",word_amount,word_row,character); } getchar(); getchar(); }
那里出现问题了。输出的结果有问题