
C Traps and Pitfalls (1988) [pdf] - aaronchall
http://www.literateprogramming.com/ctraps.pdf
======
SloopJon
The book of the same name is a decent third book on C: K&R or some other
intro, Expert C Programming, then this.

~~~
bch
> The book of the same name is a decent third book on C: K&R or some other
> intro, Expert C Programming, then this.

For the curious, this paper _is_ the the basis for the aforementioned book...

"This paper, greatly expanded, is the basis for the book C Traps and Pitfalls
(Addison-Wesley, 1989, ISBN 0–201–17928–8); interested readers may wish to
refer there as well."

~~~
McUsr
Andrew Koenig, the author of this paper/book, is also co-author of
Accellerated C++, which I can whole heartedly recommend. [Addison Wesley
ISBN-10: 0-201-70353-X]

------
ouah
"Incidentally, it is a common misconception that if c is a character variable,
one can obtain the unsigned integer equivalent of c by writing (unsigned) c.
This fails because a char quantity is converted to int before any operator is
applied to it, even a cast. Thus c is converted first to a signed integer and
then to an unsigned integer, with possibly unexpected results."

The "even a cast" part is wrong. The usual arithmetic conversions (including
the integer promotion) is not done with the cast operation in C.

------
mpu
Lots of code in there is deprecated. Don't use it.

~~~
krylon
Well, that is kind of to be expected, the paper is nearly thirty years old. It
is still an interesting read, though, if one uses C a lot.

Some of the advice _does_ seem odd to me, such as the warning regarding
bitwise vs. logical operators.

