REVIEW - C Traps and Pitfalls

Title:

C Traps and Pitfalls

Author:

Andrew Koenig

ISBN:

0201179288

Publisher:

Addison-Wesley Professional (1988)

Pages:

147pp

Reviewer:

Francis Glassborow

Reviewed:

June 2000

Rating:

★★★★★

An intimate knowledge of this book will reduce the bug rate in your C and low-level C++ code by at least 90%.

This book has been around for a long time, at least since 1988 when it was reprinted with corrections (in November of that year). As far as I know that was the last time that any changes were made to the text. The author tells me that there never will be any more because he no longer has one of the typefaces so making any changes now would cause the pagination to change. That means that if you are so remiss as not to have a copy you can safely go and buy one in the certain knowledge that there will be no future changes. If you are wondering about a completely new edition to cover C99 (the latest version of C) then I can assure you that the author has his hands full trying to master C++'s traps and pitfalls. If you are a newcomer, please do not take that last sentence seriously, Andy is one of the top dozen C++ experts in the World.

Why am I writing a review now? Well I am sure that a review of this book was one of the first reviews I ever wrote, but it has got lost. Discovering that this book has been continuously in print for more than thirteen years and still sells a couple of thousand copies a year I thought it was past time that I replaced that missing review.

However reviewing this book is almost impossible because I have lived with it close to hand for almost as long as I have known C. It is as fresh today as it was when it was first written. C programmers should know it from cover to cover. Too many do not or less buggy code would be being written. It carefully catalogues all the common causes of error as they were for those using K&R C. It recommends practice to avoid these problems. ISO/ANSI C made some changes so that you will find places where the author appears to fall into a trap. If you look carefully at page 35 you will find such an 'error.' However every of the itemised trap or pitfall is as valid today as on the day when it was first written.

C++ programmers should read it as soon as they start dabbling with low level code where they are open to falling into those traps that Andy first documented in the 1980s. Again, the evidence is that too many have never read it and have their bruised and broken code to prove it.

If you are familiar with Andy's more recent books I should warn you that his writing was not quite so smooth but that his sense of humour was pushing through even then (read the dedication, and if you are interested one of them finally did the honourable thing and married the other. And, yes, that is Barbara Moo that some of you heard speak at the 1999 Autumn JaCC.) An intimate knowledge of this book will reduce the bug rate in your C and low-level C++ code by at least 90%.


Book cover image courtesy of Open Library.