"The C programming Language". Awesome book. By Brian W. Kernighan and Dennis M. Ritchie.

You want to learn to program? Read this book. You already know how to program in other language and want to learn C? Read this book. You already know some C but you want to have a good time. Read this book.

I've really enjoyed the lecture and the approach they take to C language and programming in general. With non-solved exercices in the end of each chapter, you are able to check out if you have learned all the theory explained. The exercises are quite simple but you have always the feeling of moving forward.

This post is not just about saying this book is awesome but about the cool stuff you can do while you are reading the book. For example, you will use the standard (stdlib.h) library or the string.h library. Cool stuff you can do while learning is to take a look how some functions you use from this libraries have been implemented. This way you are removing a layer of magic and see actually that you could write the standard library by yourself (you don't have to! is already written, but you could).

First of all: download the libC source code.

$ apt-get source libc6-dev

$ cd eglibc-2.13/

We can search the PI constant in math/math.h file:

$ grep M_PIl math/math.h  
# define M_PIl        3.1415926535897932384626433832795029L  /* pi
*/

We can see the constant limits of the diferent data types in include/limits.h, the definitions of EXIT_FALIURE and EXIT_SUCCESS in stdlib/stdlib.h,  and a long etc.

The idea is not open random files and see the soruce code of random functions/definitions but, while you are programming and using a function of the libc just see how this function has been implemented by looking the source code. This way you'll learn a lot! I promise. How find the correct file? Use the commands grep and find, they are your best friends.

Another cool thing you can try to do while you are reading the book is try to implement basic UNIX commands like echo, cat, grep, wc, find, ls, etc... It's very funny and you realize that most of the commands are very very simple. You'll have to parse the arguments (required and optional), read files, print just the results requested in the parameters... it's a very nice exercice and you won't end up the ideas because you always can do a "man echo" and discover new parameters (such as -n) that you can include in your program.

And that's all.

Ah! One more thing! I recommend 100% this book, but if you have problems with english and you prefer to read a really good manual in Spanish, take a look to "Introducción a la programación en C", by Andrés Marzal and Isabel Gracia of the Departamento de Lenguajes y Sistemas Informáticos of the University of Jaume I. This book has been published with a Creative Commons License and you can download it from the Internet.  You can find another book from the same guys called "Ejercicios en C" that have a recopilation of all the resolved exercices proposed in the main book (339 exercices in total).

Regards, Jan.