Errata for K&R

K&R, a.k.a. The C Programming Language is, so far as I can tell, the best book ever written about C. It is well written, and almost invariably correct.

The following is a list of the errors I am aware of, sorted by page number. It is a very small list for a 200+ page book about the C language; an equivalent list for Herbert Schildt's C: The Complete Reference would be at least 90k. (For the third edition; earlier ones were dramatically worse.)

I am probably missing several errors. Please write me if you think you know of any I'm missing.

Currently known:

Various places
Several functions are provided which implement parts of the standard library; this is technically not allowed, as those names are reserved. e.g., if one wished to implement a quicksort function, one would be obliged to name it something other than "qsort".
Page 114
Near the top, a quote is missing after the name Jan.
Page 117
The sample program increments argv[0]. Although argv is modifiable, and argv[0][0] is modifable (if argv[0] is not a null pointer), argv[0] is not modifiable. (At least, not always.)
Page 119
The sample program casts function pointers in a very dubious way.
Page 167
It is asserted that the pointer returned by malloc or calloc must be converted to an appropriate type; this is not true in ANSI C.
Page 241
Of course, actually the library is a part of the language, and although it must be possible to take the address of the functions in the library, a compiler is allowed to inline and optimize calls, and many do. However, it is a part of the language definition. (Of course, it's not a part of a freestanding implementation; in this respect, the book is correct.)

Comments about this web page can be sent to: