Open C Book

The Open C Book Project

The Open C Book Project aims to provide a comprehensive, up-to-date, and completely free book which teaches C programming in a Posix
compliant environment, with an emphasis on using Open Source tools.

This book is a work in progress and is the work of many individuals. Many sections do not yet exist and some of those that do exist need to be updated. Chapters and sections that are not yet written are marked by preceding their names with **, those in progress and still needing work are marked with *. If you are interested in helping with this project, send email to the Open C Book Project developers mailing list . The latest version of this document is always available from the Open C Book Project web site.

Table of Contents
I. *The C Language
1 **Introduction
2 *Basics Of A C Program
2.1 Getting Started in C
2.2 The Characters Used
2.3 Summary
3 *Data Types
3.1 Basic Variable Types
4 **Operators
5 *Flow Control
5.1 Compound Statements
5.2 If
5.3 Switch
5.4 Break and Continue
5.5 While
5.6 Do-while
5.7 For
5.8 Goto
6 *Functions
6.1 Definition of a Function
6.2 Function Declaration and Function Prototypes
7 **The Preprocessor
II. **The Posix Development Environment
8 **Introduction to the Posix Environment
9 **Compiling
10 **Debugging
11 **Profiling
12 **Revision Control
III. **Advanced Topics
13 **Program Design
14 **Interprocess Communication
15 **Network Programing
16 **Threads
17 **Select, Poll, KQueue
IV. Appendices
A. Contributors
List of Tables
2-1. Examples of valid and invalid variable names
2-2. Special characters
List of Examples
2-1. Hello World program
3-1. A simple adding program
6-1. Function definition
6-2. A simple adding program with functions
6-3. A simple program with a function prototype

This, and other documents, can be downloaded from

For questions about the Open C Book Project, read the documentation.