C
C Programming
A modular C library: foundations through systems topics, with a separate workbook for extra drills and projects.
This book uses C17 as the default dialect. Examples prefer:
gcc -std=c17 -Wall -Wextra -Wpedantic -o prog prog.c
./progClang is fine as a drop-in for learning:
clang -std=c17 -Wall -Wextra -Wpedantic -o prog prog.cWho this is for
Path A — Beginner (language first)
Start at Module 1 and move in order through Module 5 before jumping ahead. Type every full program. Treat warnings as errors in practice (-Werror once you are comfortable). Goal: confident control flow, functions, arrays/strings, and a first honest encounter with pointers.
Path B — Systems-oriented (already know some C syntax)
Skim Module 1 for the compile/link mental model and warning flags, then prioritize Modules 6–8 (pointers, structures, file/system I/O). Use Modules 11–15 when you need sockets, embedded patterns, performance, testing, or threads. Still run Module 1’s multi-file and I/O labs if those habits are rusty.
Both paths should enable warnings early and avoid treating “it compiled” as “it is correct.” Undefined behavior is introduced early for a reason.
How to use this book
- Read a section, then type the programs (do not only read them).
- Compile with
-std=c17 -Wall -Wextra -Wpedantic. - Break one thing on purpose; read the diagnostic; fix it.
- Do the chapter exercises before moving on.
- Use the workbook when you want more reps or a larger project—not as a substitute for chapter work.
How to compile examples
From any directory where you saved a single-file example:
gcc -std=c17 -Wall -Wextra -Wpedantic -o hello hello.c
./helloMulti-file:
gcc -std=c17 -Wall -Wextra -Wpedantic -o app main.c util.c
# or
gcc -std=c17 -Wall -Wextra -Wpedantic -c main.c
gcc -std=c17 -Wall -Wextra -Wpedantic -c util.c
gcc -o app main.o util.oUseful extras:
| Flags | Purpose |
|---|---|
-g -O0 |
Debug builds |
-O2 |
Optimized builds |
-fsanitize=address,undefined |
Runtime checks (GCC/Clang, host-dependent) |
Workbook demos live under content/99-workbook/examples/ (per module). Some multi-file folders include a Makefile—read it, then still know how to issue the raw gcc line yourself.
Workbook (content/99-workbook)
| Area | Path | Use for |
|---|---|---|
| Examples | content/99-workbook/examples/0N-…/ |
Runnable demos aligned to modules |
| Exercises | content/99-workbook/exercises/0N-…/ |
Extra problem sets |
| Projects | content/99-workbook/projects/ |
Beginner → capstone project prompts |
Suggested rhythm: finish the module chapters → attempt workbook exercises for that module → pick a project only when the drills feel mechanical.
Appendices under content/100-appendices/ hold resources, quick reference material, and solution notes.
Modules (15 + workbook + appendices)
- Foundations and Environment — history and process model, toolchain, first programs, console I/O
- Data Types and Variables — types, storage, conversions, operators
- Control Flow — decisions, loops, non-local flow
- Functions and Modularity — design, linkage, library overview
- Arrays and Strings — contiguous data and text
- Pointers and Memory — addresses, dynamic allocation, pitfalls
- Structures and Types —
struct,union,enum, simple ADTs
- File I/O and System Programming — streams and system-facing I/O
- Modern C Standards — C99 through C23 and modern practice
- Data Structures and Algorithms — lists, trees, tables, graphs, sorting
- Network Programming — sockets and protocols
- Embedded Systems — constrained and hardware-oriented C
- Performance Optimization — measure, then improve
- Testing and Debugging — quality, debug, error handling
- Advanced Topics and Capstone — concurrency, systems topics, capstone
Plus 99-workbook (examples, exercises, projects) and appendices.
Prerequisites
- Comfort using a text editor and a terminal
- Ability to install a C compiler (GCC, Clang, or MSVC/MinGW on Windows)
- No prior programming required for Path A; Path B assumes basic syntax familiarity
Getting started
- Introduction to C — mental model and first mini-programs
- Development Environment — install and verify the toolchain
- Your First C Program — compile, multi-file, labs
- Basic I/O —
printf/scanf/fgets
Then continue through the modules in order (Path A) or jump to pointers and systems modules (Path B) once foundations are solid.