我正在尝试编写"The C Programming Language"(K&R)一书中的这段代码.它是UNIX程序的一个简单版本wc:
#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; …Run Code Online (Sandbox Code Playgroud) c ×1