Name: Anonymous 2012-09-02 1:19
So, I've been trying to learn C out of the book "The C Programming Language", and in chapter 1 it gives me a program to count words, but every time I try the code:
I try to compile it and it gives me the error "lvalue required as left operand of assignment" on line 15. I've looked it up on google and I couldn't find anything wrong with this. And from just looking at it, it looks fine.
What's going on here?
#include <stdio.h>
#define IN 1
#define OUT 0
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;
if (state == OUT){
state = IN;
++nw;
}
}
printf("%d %d %d\n", nl, nw, nc);
}I try to compile it and it gives me the error "lvalue required as left operand of assignment" on line 15. I've looked it up on google and I couldn't find anything wrong with this. And from just looking at it, it looks fine.
What's going on here?