I can't compile this code

Posted by heshim on Stack Overflow See other posts from Stack Overflow or by heshim
Published on 2010-12-31T21:35:32Z Indexed on 2010/12/31 21:54 UTC
Read the original article Hit count: 192

Filed under:
  #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; 
           else if (state == OUT) { 
               state = IN; 
               ++nw; 
           } 
       } 
       printf("%d %d %d\n", nl, nw, nc); 
   } 

I got K&R book but there are some codes that don't compile !

it gives me - 19 C:\Users\Nom\Desktop\Untitled1.c invalid lvalue in assignment


edit: now it works, thanks guys, but now it does nothing ! the printf statement doesn't work. It opens the dos console, I type anything and it just return a new line. I'm using Dev-C++ 4.9.9.2


I put the printf statement inside the while loop and it works now. thanks

© Stack Overflow or respective owner

Related posts about c