The Little Book of C

Version 0.3.2

Author

Duc-Tam Nguyen

Published

October 5, 2025

Content

A 100-step journey to learn C from first principles

Chapter 1. Getting Started with C

  1. What Is C and Why Learn It
  2. Installing a C Compiler
  3. Writing Your First C Program
  4. Understanding main and Return Values
  5. Printing with printf
  6. Comments and Code Readability
  7. Variables and Basic Types
  8. Declaring and Initializing Variables
  9. Compiling and Running Programs
  10. Common Beginner Mistakes

Chapter 2. Working with Data

  1. Integers, Floats, and Characters
  2. Type Conversions and Casting
  3. Constants and Literals
  4. Operators and Expressions
  5. Arithmetic Operators
  6. Comparison and Logical Operators
  7. Operator Precedence
  8. Reading Input with scanf
  9. The sizeof Operator
  10. Debugging Type Errors

Chapter 3. Control Flow

  1. The if Statement
  2. The else and else if Clauses
  3. Nested Conditionals
  4. The switch Statement
  5. The while Loop
  6. The for Loop
  7. The do-while Loop
  8. Breaking and Continuing Loops
  9. Using goto Safely (and Why to Avoid It)
  10. Patterns of Control Flow

Chapter 4. Functions and Scope

  1. Defining and Calling Functions
  2. Function Parameters and Return Values
  3. Local and Global Variables
  4. Scope and Lifetime
  5. Header Declarations (.h files)
  6. Pass by Value Explained
  7. Recursion and Base Cases
  8. Function Prototypes and Order
  9. Inline Functions
  10. Organizing Code with Functions

Chapter 5. Arrays and Strings

  1. Declaring Arrays
  2. Indexing and Bounds
  3. Multidimensional Arrays
  4. Iterating over Arrays
  5. Strings as Character Arrays
  6. String Literals and Null Terminators
  7. Common String Functions (strlen, strcpy, strcmp)
  8. Inputting Strings
  9. Arrays vs. Pointers (A Gentle Intro)
  10. Common Array Pitfalls

Chapter 6. Pointers and Memory

  1. What Is a Pointer
  2. The Address-of (&) and Dereference (*) Operators
  3. Pointer Arithmetic
  4. Arrays and Pointers Revisited
  5. Function Parameters with Pointers
  6. Dynamic Memory Allocation with malloc
  7. Using free Safely
  8. Pointer to Pointer
  9. NULL and Dangling Pointers
  10. Debugging Memory Errors

Chapter 7. Structures and Modular Design

  1. Defining struct Types
  2. Accessing Structure Members
  3. Structures and Functions
  4. Nested Structures
  5. Arrays of Structures
  6. Typedefs for Simpler Names
  7. Enums and Symbolic Constants
  8. Unions and Shared Memory
  9. Organizing Code into Modules
  10. Splitting Code into .c and .h Files

Chapter 8. The Power of the Preprocessor

  1. What Is the Preprocessor
  2. #include and Header Guards
  3. Defining Macros with #define
  4. Working with Paths and Filenames
  5. Conditional Compilation (#if, #ifdef)
  6. Function-like Macros
  7. Debugging with #error and #warning
  8. Built-in Macros (__FILE__, __LINE__)
  9. The Compilation Pipeline (Preprocess → Compile → Link)
  10. Balancing Macros and Functions

Chapter 9. Files, Tools, and Concurrency

  1. File I/O Basics: fopen, fclose
  2. Reading and Writing Files
  3. Working with Binary Files
  4. Error Handling in File Operations
  5. Command-Line Arguments
  6. Using make and Makefiles
  7. Debugging with gdb
  8. Understanding Linking and Libraries
  9. Simple Threads with <threads.h>
  10. Synchronization and Data Safety

Chapter 10. Putting It All Together

  1. Mini Project 1: Text Analyzer
  2. Mini Project 2: Guessing Game
  3. Mini Project 3: Calculator
  4. Mini Project 4: File Copy Utility
  5. Mini Project 5: Simple Logger
  6. Mini Project 6: Contact Book
  7. Mini Project 7: Matrix Operations
  8. Mini Project 8: JSON-like Parser
  9. Mini Project 9: Mini Shell
  10. Mini Project 10: Tiny HTTP Server