C:下面的代码无法编译?

0 c

  #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); 
   } 
Run Code Online (Sandbox Code Playgroud)

我得到了K&R书,但有一些代码无法编译!

它给了我 - 19 C:\ Users\Nom\Desktop\Untitled1.c赋值中的lvalue无效


编辑:现在它工作,谢谢你们,但现在它什么都不做!printf语句不起作用.它打开dos控制台,我输入任何内容,它只返回一个新行.我正在使用Dev-C++ 4.9.9.2


编辑:我将printf语句放在while循环中,现在可以正常工作了.谢谢

Rob*_*rtB 6

if (c == ' ' || c == '\n' || c = '\t')最后=应该是==

  • @heshim:输入内容,然后发送EOF.我认为Windows上的Ctrl + Z ... K&R非常以Unix为中心. (2认同)