Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
The point was to use an assignment operator instead of a comparison operator to create an infinite loop so that the reader could identify the operator used in the loop's condition as the fault of the code snippet.

I think we all agree that the author's intent was to flag the assignment instead of comparison in the loop condition, and you can check that by looking at the answers in the back of the book. :p

He writes:

This is probably the most common mistake made by C programmers. The assignment operator (=) is used instead of the logical equality operator (==). Since the assignment operator is perfectly legal inside an expression, the compiler won't find this error. This is an annoying error you'll encounter again and again! Consider using 20 == i instead of i == 20.

(Thanks Amazon!)

Without additional context, we don't know if it's an infinite loop or a no op loop. (Depends mainly on how "true" is defined).

Plus, the suggested trick of reversing the operands wouldn't necessarily help here as we don't know if true is declared as const, and it certainly isn't a literal. (However, if stdbool was included true = done would get the compiler to scream).

B
 
I think we all agree that the author's intent was to flag the assignment instead of comparison in the loop condition, and you can check that by looking at the answers in the back of the book. :p
B

Haha, I didn't even know the answers were in the back of the book! I wasn't expecting that since my other book doesn't have answers in it! Duh!!!

Thanks, that'll help some when I get stuck!

Sorry I didn't know they were there!
 
ugh, I wish I had a dollar every time I've seen or made an error related to checking equality :(

i've been programming a while now and STILL make those..
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.