我正在测试“ C编程语言”一书中的代码,我想知道EOF的价值是什么,如何找到它?我尝试使用某种类型的指针引用该值,但是我只收到一个const指针错误。无论如何,下面是我的代码,我想知道为什么在单击Enter时为什么没有输出:
#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);
}
答案 0 :(得分:0)
ggplot