Word Counting program not understanding
Hello Masters ,
I am learning C programming from K & R text .
i dont understand the wordcounting programing .
How is working ?
please help me
Code:
#include<stdio.h>
#define IN 1
#define OUT 0
main()
{
int c,n1,nw,nc,state;
state = OUT;
n1 = nw = nc = 0;
while((c =getchar()) != EOF )
{
++nc;
if(c == '\n')
++n1;
if(c == ' ' || c == '\n' || c == '\t')
state = OUT;
else if(state == OUT)
state = IN;
++nw; // How to show it 0 a when I exit without press any key ?
}
}
printf("%d %d %d\n",n1 ,nw,nc);
}
How did here use the sate ,IN ,OUT ?
any explain the progaram
thanks in advance