4 ms·
C Traps and Pitfalls (1988) [pdf]
- SloopJon 11y agoThe book of the same name is a decent third book on C: K&R or some other intro, Expert C Programming, then this.
- bch 11y ago> 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 11y agoAndrew 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]
- mintisan 11y ago+32
- mpu 11y agoLots of code in there is deprecated. Don't use it.
- krylon 11y agoWell, 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.
- ouah 11y ago"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.