Having looked at Simon Long’s book about C programming, I thought I should give a mention to the one that has been long regarded as the C Bible, and the one that Simon suggests as further reading: the C Programming Language by Brian W. Kernighan and Dennis Ritchie.
Kernighan and Ritchie not only wrote the book, they wrote the language, too (well, Ritchie did) . They then went on to revise the language and produce a new edition of the book. So if your grandfather offers to lend you a copy of K&R’s first edition, just politely say, “no, thanks”, it’s the second edition that you need.
The K&R book is quite short – less than 300 pages – and in two main parts, the first part is a tutorial which covers the main aspects of the language and the second is a series of chapters going into the different parts of the language in much more depth.
The tutorial gives plenty of examples albeit fairly short ones and you can get a pretty good idea of the language just from these 40-odd pages. I was a professional C programmer for a number of years and the tutorial part was all I needed to get started in C programming.
The rest of it can act as a reference or for more in-depth reading. You will need to read this as you become more a proficient and experienced C programmer.
As Kernighan and Ritchie say in the book, C is a small language and thus does not require a large book to explain it. However, while is may be quick to learn, it takes rather longer to become proficient and it can be quite challenging to produce complex programs that might be more easily created in a higher level language such as Python.
One of the main philosophies behind C is that the programmer should be trusted to know what she is doing. Programs like Java provide certain protections against programmer errors, C doesn’t provide much protection beyond simple type-checking of data (and even that can be circumvented). For example, in Java if you declare an array of, say, 20 items, it will throw up an error if you try and set a value in the 21st element. Not so C. The C approach is that if the programmer is writing to the 21st element he must be doing so for a reason.
In addition to the main parts of the book, there are two prefaces (one to the first and one to the second editions) that give a short history of C and three appendices. The first appendix is a C reference manual which provides formal definitions for all of the language constructs; the second is a description of the standard C library which provides function for file handling, input/output, maths, string handling an other useful stuff; the last appendix is of historical interest only, these days, as it gives the differences between the first and second versions of the languages.
So is this book better than Simon Long’s? It more comprehensive but Simon Long doesn’t claim his book to be anything other than an introduction. Long’s book is similar to the tutorial part of K&R but written and designed to be more accessible. It also has the advantage of being cheaper (or, indeed free, if you download the pdf).
As I mentioned at the beginning. K&R is thought by many people to be the bible of C so if you want to know C inside out (and it would help to have some experience as a programmer), it’s a good book to have in your library. If it is a passing interest that you have then an introductory text will probably suffice.
As part of my post Which Language for the Raspberry Pi, I also wrote A Little Bit of C.