The title of the book is obviously false; I am still waiting to meet the inexperienced programmer that is able to effectively acquire the knowledge of a new non-trivial programming language in just a few weeks. Nevertheless, the content of a book with such a title may still be satisfactory. In this case, it is not. In fact, it seems to be the worst book on C I have ever seen. (I have seen worse, but they were on C++.) I do not want to go into fine details, so I shall give some general remarks, seasoned with a few examples.
-
The authors do not care about ANSI-C: Their deviations from the standard start with many cases where
main()
returnsvoid
and culminating when they do not distinguish between standard and non-standard library functions. - The book advocates a bad and dangerous, coding style (in general, most of my students write better code); functions are way too long (e.g., 90 lines), algorithms are primitive in the worst possible sense and I have stopped counting the cases where global variables were used (with not even a superficial benefit). Regarding the latter, here is a quotation from one of the book's DO-boxes (p. 293): 'DO pass data items as function parameters instead of declaring them as global if they're needed in only a few functions.' [hope springs eternal :-]
- Code examples have bugs:
-
When it has
main()
that returns typeint
, there are many cases where the return statement has no expression toreturn
(e.g., pp. 419, 443, 478, 479, 481, 483 :-). - Among several cases that I have seen, where dynamically allocated memory was used, only in one case was there code for freeing the memory allocated.
-
Given the definition
char input[80], *ptr;
here is the control expression of a while loop, p. 238:
while ( *(ptr = gets(input)) != NULL )
It is not only the case that input may overflow, but this code compiles only ifNULL
is#defined
to be 0. HadNULL
been defined to be(void*)0
(which is a common practice), this code would not have been compiled. All in all, it shows that the writer does not distinguish betweenNULL
and'\0'
. -
p. 417: 'Here's the code to delete the first element in a linked list:
free(head); head = head->next;
For the novices; it is forbidden to usehead->next
afterhead
was freed. - If 21 days is not enough for you, you get a Bonus Week - seven chapters about OOP. I shall skip the nonsense that is spread all over and give a simple hint; on p. 644 it tells the interested reader to purchase other books on C++, yet the only book that is mentioned by title is - you guessed right - Sams Teach Yourself C++ in 21 Days . You might guess what was the only reason they had not mentioned Stroustrup's book.
- Appendix D refers to portability issues, so I hoped that at least here they would be careful - I was wrong. Read this pearl, taken from p. 782: Regarding order of members in a structure, they say: There isn't a standard stating that a certain order must be followed. Alas, Kernighan&Ritchie disagree, K&R2 p. 213: The members of a structure have addresses increasing in the order of their declarations.
The bottom-line; keep a safe distance from this book. This book is a time-bomb, waiting to blow up your programs.