Hello Masters ,
I am learning C programming from K & R text .
i dont understand the wordcounting programing .
How is working ?
please help meHow did here use the sate ,IN ,OUT ?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); }
any explain the progaram
thanks in advance