The C Programming Language, Part 3
The book in the middle with the red title -- The C Answer Book -- provided solutions to the exercises presented in The C Programming Language (topmost book). It was neatly done, and kept pace with the concepts presented in the source material. Depending on how you learn, the answer book can be useful. Back in the day, before the internet matured, it certainly was. Today, it's not as essential because sample code abounds.
The book at the bottom was the second edition of The C Programming Language and described the ANSI standard. A new one on Amazon sold for about $60, which made my first edition quite the bargain. Emphasizing C's main strength, and at the same time, acknowledging a major source of difficulty, K&R expanded Chapter 5: Pointers and Arrays with diagrams of how memory was organized, how arrays were imagined, and how pointers pointed. The exercises were also more involved, and the chapter ended with code to parse complex declarations.
One of my favorite features introduced by ANSI C was the function prototype declaration. It made code more readable for the programmer, and errors easier to detect for the compiler. Using K&R's example on page 26, an early declaration of the power() function would like like this:
whereas the ANSI C standard would require you to identify the parameters:
int power(int, int);
ANSI C also introduced 5 new keywords: void, enum, signed, const, and volatile. The last two deserve some elaboration. While const was intuitively grasped and used often, the meaning of volatile was less clear and the keyword rarely used. A const object, once initialized, cannot change throughout its life. const also informed the compiler the object was a candidate for optimization, and as such, could be placed in read-only memory. In opposite fashion, a volatile object instructed the compiler to suppress any optimization directives for that object because doing so might break the code. For example, a memory location might have multiple direct and indirect pointer references to it, and without the volatile qualifier, aggressive compiler optimizations might remove seemingly redundant, but actually needed, pointers.
One keyword was removed by ANSI C: entry. What it meant or did, I can only guess. The keyword was simply reserved and never implemented.
Sadly, another item was removed from the book: the playful Chapter 0 reference for the Introduction. Apparently, the SI in ANSI could also mean "Serious Implementation." I have uploaded the page from both books for posterity (click on images to enlarge):
|K&R C Intro - 1st Ed|
|K&R C Intro - 2nd Ed|
One might ask if C is still relevant today. Given C++ and Java, modern bread-and-butter languages, or Python, a language growing in popularity, or Swift, a language... uh... "tailored" for iOS devices, is C still useful? C's expressiveness and conciseness make it easy for me to say "yes." But don't take my word for it.
Bravo, professor. Bravo.
Here are links to Part 1 and Part 2 of this Bookshelf Classic.