The K&R program run correct, almost . . . no termination condition. The gentlemen K&R don't like this.
Your code: For what "y"? In line 12: int c = 0; And "return(0);" is missing.
Code:
//Zeilen, Wörter und Zeichen zählen, K&R S. 20 (34)
#include <stdio.h>
#define IN 1
#define OUT 0
int main(void)
{
int c, state;
int new_line, new_word, char_number;
state = OUT;
new_line = new_word = char_number = 0;
do
{
c = getchar();
++char_number;
if (c == '\n')
{ ++new_line; }
if (c == ' ' || c == '\n' || c == '\t')
{ state = OUT; }
else if (state == OUT)
{
state = IN;
++new_word;
}
}while (c != '0');
printf("\n%3d %3d %3d\n\n", new_line, new_word - 1, char_number);
return(0);
}
"new_word - 1" because otherwise the program count also the "0".