Learn C Programming With 9 Excellent Open Source Books

Books are very personal things. And programming books are no exception. We all form bonds with programming books that help master the rudiments of a language, and then be able to move on to fully exploit the language’s flexibility.

I have carefully considered the open source C books that are closest to my heart. I have identified 9 books that mean the most to me.

C is a general-purpose, procedural, portable, high-level programming language that is one of the most popular and influential languages. It was designed to be compiled using a straightforward compiler, to provide low-level access to memory, to provide language constructs that map efficiently to machine instructions, and to require minimal run-time support. Many programming languages owe a considerable debt to C. It has become something of the lingua franca in the programming world.

C is fairly simple to understand. It allows the programmer to organize programs in a clear, easy, logical way. It is a very flexible, practical and compact language combined with an easy to read syntax. Code written in C runs quickly, with easy access to the low level facilities in the computer. Compiler directives make it possible to produce a single version of a program compiled for different architectures.

C is about freedom. It therefore makes sense to learn C with books that also embody freedom. Take a look at my open source picks and see if any of them grab your fancy. Put the kettle on and enjoy.

The C Book

The C Book

By Mike Banahan, Declan Brady and Mark Doran (350 pages)

The C Book is designed for programmers who already have some experience of using a modern high-level procedural programming language. The book concentrates on the things that are special to C. In particular, it is the way that C is used which is focused on.

Chapters include:

  • An Introduction to C
  • Variables and Arithmetic – introduces some of the fundamentals of C, including keywords and identifiers, declaration of variables, real types, integral types, expressions and arithmetic, and constants
  • Control of Flow and Logical Expressions – looks at the various ways that the control of flow statements can be used in a C program, including some statements that have not been introduced so far. Control of flow, more logical expressions, and strange operators
  • Functions – the type of functions, recursion and argument passing, and linkage
  • Arrays and Pointers – arrays, pointers, character handling, sizeof and storage allocation, pointers to functions, expressions involving pointers, arrays, the & operator and function declarations
  • Structured Data Types – structures, unions, bitfields, enums, qualifiers and derived types, and initialization
  • The Preprocessor – how the preprocessor works, and directives
  • Specialized Areas of C – declarations, definitions and accessibility, typedef, const and volatile, and sequence points
  • Libraries – diagnostics, character handling, localization, limits, mathematical functions, non-local jumps, signal handling, variable numbers of arguments, input and output, formatted I/O, character I/O, unformatted I/O, random access functions, general utilities, string handling, and date and time
  • Complete Programs in C – putting it all together, arguments to main, interpreting program arguments, a pattern matching program, and a more ambitious example

The authors give the reader permission to do anything they want with the book provided there is an acknowledgement of the authors and their copyright. From what Mike Banahan has confirmed, the book is effectively under the Creative Commons License.

C Elements of Style

C Elements of Style

By Steve Oualline (265 pages)

C Elements of Style is a useful guide which covers the principals of good programming style, teaching C and C++ programmers how to write code that can be easily read, understood, and maintained by others. Whether you are a student or professional programmer, you will benefit from the many tips and techniques for constructing elegant, reliable code.

The book attempts to show readers how to build a good programming style into your code. Since computer reads only the code and the human concentrates on the comments, a good programming style pertains to both parts of a program.

The ultimate goal is to build a well-designed, well-written code which not only make an effective use of the computer and but also contains careful constructed comments to help humans understand it. This condition will ease the debugging, maintenance and enhancement process, which will eventually improve the readability, portability, reliability and maintainability of your code.

Inside, you will find guidelines on writing comments, program heading, determining variable names, statement formatting, statement details, writing preprocessor, organizing directories and creating makefile.

This book is published under the Creative Commons License.

Build Your Own Lisp

Build Your Own Lisp

By Daniel Holden (212 pages)

Learn the C programming language and at the same time learn how to build your very own programming language, a minimal Lisp, in under 1000 lines of code.

This book is for anyone wanting to learn C, or who has once wondered how to build their own programming language. It is not designed as a first programming language book, as you need some programming experience to make your way through the content.

Build Your Own Lisp is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0.

A paperback is available to purchase from Amazon.

The GNU C Reference Manual

By Trevis Rothwell, James Youngman (91 pages)

The GNU C Reference Manual is a reference for the C programming language and aims to document the 1989 ANSI C standard, the 1999 ISO C standard, and the current state of GNU extensions to standard C. It is not designed for new programmers.

Chapters cover:

  • Lexical Elements – describes the lexical elements that make up C source code after preprocessing. These elements are called tokens. There are five types of tokens: keywords, identifiers, constants, operators, and separators
  • Data Types – examines primitive data types, enumerations, unions, structures, arrays, pointers, incomplete types, type qualifiers, storage class specifiers, and renaming types
  • Expressions and Operators – also looks at incrementing / decrementing, arithmetic operators, complex conjugation, comparison operators, logical operators, bit shifting, bitwise local operators, pointer operators, the sizeof operator, type casts, and more
  • Statements – read about labels, expression statements, the if statement, the switch statement, the while statement, the do statement, the for statement, blocks, the null statement, the goto statement, the break statement, the continue statement, the return statement, and the typedef statement
  • Functions – learn about function declarations, function definitions, calling functions, function parameters, variable length parameter lists, calling functions through function pointers, the main function, recursive functions, and more
  • Program Structure and Scope – looks at the big picture
  • A Sample Program – a complete program written in C, consisting of both a C source file and a header file. This program is an expanded version of the quintessential “hello world” program, and serves as an example of how to format and structure C code for use in programs for FSF Project GNU

The book is available under the terms of the GNU Free Documentation License, Version 1.3 or later.

The GNU C Programming Tutorial

By Mark Burgess, Ron Hale-Evans (290 pages)

The GNU C Programming Tutorial introduces the reader to the basic ideas in a logical order. It offers detailed coverage of each of the main elements of the C language and how to program in C, with special emphasis on the GNU/Linux compiler and associated software.

There are chapters devoted to functions, variables and declarations, scope, expressions and operators, parameters, pointers, decisions, loops, arrays, strings, input and output, and much more.

The GNU C Programming Tutorial is released under the GNU Free Documentation License, Version 1.1.

Essential C

By Nick Parlante (45 pages)

This Stanford CS Education is a fairly brief document which explains all the common features and techniques for C. The coverage is pretty quick, so it is targeted at a programmer with a background in another language.

Topics include variables, int types, floating point types, promotion, truncation, operators, control structures (if, while, for), functions, value parameters, reference parameters, structs, pointers, arrays, the pre-processor, and the standard C library functions.

Table of Contents:

  • Introduction
  • Basic Types and Operators
  • Control Structures
  • Complex Data Types
  • Functions
  • Odds and Ends
  • Advanced Arrays and Pointers
  • Operators and Standard Library Reference

The author’s description indicates this book is issued under an open-source like license.

Beej’s Guide to C Programming

By Brian “Beej” Hall (130 pages)

Beej’s Guide to C Programming tries to lead the reader from complete and utter sheer lost confusion on to the sort of enlightened bliss that can only be obtained though pure C programming.


  • Programming Building Blocks
  • Variables, Expressions, and Statements – A variable is simply a name for a number. An expression in C consists of other expressions optionally put together with operators. Examines the if, while, do-while, and the for statements
  • Building Blocks Revisited
  • Functions – put some of those building blocks in their own functions when they become too large, or when they do a different thing than the rest of the code
  • Variables, the Sequel – talks about variable scope and storage classes
  • Pointers – they are the address of data. Just like an int can be 12, a pointer can be the address of data
  • Structures – a construct that allows you to logically group variables into groups. You can then reference the group as a whole
  • Arrays – a linear collection of related data
  • Strings – a string in C is a sequence of bytes in memory that usually contains a bunch of letters
  • Dynamic Memory – explores the malloc(), free(), realloc(), and calloc() functions
  • More Stuff – topics include pointer arithmetic, typedef, enum, struct declarations, command line arguments, multidimensional arrays, casting and promotion, incomplete types, void pointers, NULL pointers, and static keywords
  • Standard I/O Library – used for reading from and writing to files
  • String Manipulation – find functions for pulling substrings out of strings, concatenating strings together, getting the length of a string, and more
  • Mathematics – functions that will serve your general purpose mathematical needs

This book is licensed under the Creative Commons Attribution-Noncommercial- No Derivative Works 3.0 License.

Modern C

By Jens Gustedt (310 pages)

Modern C seeks to motivate the reader to climb to higher levels of knowledge. The book is divided into five levels:

  • First level – provides the reader with the very basics of C programs, their purpose, their structure, and how to use them
  • Second level – details most principal concepts and features such as control structures, data types, operators and functions. It aims to provide the reader with a deeper understanding of the things that are going on with running programs
  • Third level – goes to the heart of the C language. It fully explains pointers, familiarizes you with C’s memory model, and allows you to understand most of C’s library interface.
  • Fourth level – goes into detail in specific topics, such as performance, reentrancy, atomicity, threads and type generic programming
  • Fifth level – discusses the author’s ideas for a future development of C

This book is licensed under the Creative Commons Attribution-Noncommercial- No Derivative Works 3.0 License.

An Introduction to GCC

An Introduction to GCC

By Brian Gough (144 pages)

An Introduction to GCC provides an introduction to the GNU C and C++ Compilers, gcc and g++, which are part of the GNU Compiler Collection (GCC).

This book explains how to use the compiler itself. Based on years of observation of questions posted on mailing lists, it guides the reader straight to the important options of GCC.


  • Introduction
  • Compiling a C program – describes how to compile C programs using gcc. Programs can be compiled from a single source file or from multiple source files, and may use system libraries and header files
  • Compilation options – describes other commonly-used compiler options available in GCC. These options control features such as the search paths used for locating libraries and include files, the use of additional warnings and diagnostics, preprocessor macros and C language dialects
  • Using the preprocessor – describes the use of the GNU C preprocessor cpp, which is part of the GCC package. The preprocessor expands macros in source files before they are compiled. It is automatically called whenever GCC processes a C or C++ program
  • Compiling for debugging – provides the -g debug option to store additional debugging information in object files and executables. This debugging information allows errors to be traced back from a specific machine instruction to the corresponding line in the original source file
  • Compiling with optimization – GCC is an optimizing compiler. It provides a wide range of options which aim to increase the speed, or reduce the size, of the executable files it generates
  • Compiling a C++ program – describes how to use GCC to compile programs written in C++, and the command-line options specific to that language
  • Platform-specific options – describes some of the options available for common platforms: Intel and AMD x86 options, x86 extensions, x86 64-bit processors, DEC Alpha options, SPARC options, POWER/PowerPC options, Multi-architecture support, and floating-point issues
  • Troubleshooting – GCC provides several help and diagnostic options to help troubleshoot problems with the compilation process
  • Compiler-related tools – describes a number of tools which are useful in combination with GCC. These include the GNU archiver ar, for creating libraries, and the GNU profiling and coverage testing programs, gprof and gcov
  • How the compiler works – describes in more detail how GCC transforms source files to an executable file. Compilation is a multi-stage process involving several tools, including the GNU Compiler itself (through the gcc or g++ frontends), the GNU Assembler as, and the GNU Linker ld. The complete set of tools used in the compilation process is referred to as a toolchain
  • Examining compiled files – describes several useful tools for examining the contents of executable files and object files
  • Common error messages – describes the most frequent error and warning messages produced by gcc and g++. Each case is accompanied by a description of the causes, an example and suggestions of possible solutions
  • Getting help – if readers encounters a problem not covered by this introduction, there are several reference manuals which describe GCC and language-related topics in more detail

This book is published under the GNU Free Documentation License

Here are some informative C Books to download without charge, but which regrettably are not released under an open source license, or where license information is unclear. In no particular order:

Introduction to C Programming – by Rob Miles
The New Standard C: An Economic and Cultural Commentary – by Derek M. Jones
Object-Oriented Programming with ANSI-C – by Axel-Tobias Schreiner
Writing Bug-Free C Code – by Jerry Jongenius

And finally, my recommendation if you want to buy a canonical reference book is this title: The C Programming Language. Terse, not for beginners, but widely regarded as the classic C programming book.


Leave a Reply