On Mon, 10 Oct 2011 14:08:44 -0400, Anthony <> wrote:
> if (c == ' ' || c == '\n' || c = '\t')
....
> My compiler says
>
> line14 : lvalue required as left operand of assignment
....
> The above is copied straight out of the book yet it still won't compile
It was copied out of the book, but you've introduced an error in your
copying. Look closely at the last (intended) comparison on that line.
This is something that many beginning C programmers have problems with.
Note the difference between the assignment operator ( = ) and the
equality operator ( == ). Even some of us who have been programming
in C for decades occasionally produce typos like this, which is why some
people prefer to write comparisons like
if (' ' == c)
instead of
if (c == ' ')
because if the == is mistyped as =, the former will cause the compilation
error you've observed, while the latter will accidentally change the
value of c, and produce debugging headaches.
--
Morris Keesan --