I am new to programming in C and I am learning from "The C Programming Language", I am trying to write a program that will count input lines words, and characters, I've checked multiple times and I'm fairly certain this is the exact code in the book, but i am not getting any output from it, any suggestions?
Code:
#include <stdio.h>
#include <stdlib.h>
#define IN 1
#define OUT 0
main()
{
int c, nl, nw, nc, state;
state = OUT;
nw = nc = nl = 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", nw, nl, nc);
}