Companion code
Every listing, ready to build
166 files across 15 chapters. Each one was compiled with the book's flags and behaves as the text says.
Download everything (104 KB) Set up your workbench first
Build C files with the book's standard line, and C++ files from Chapter 12 on with its C++ twin:
gcc -std=c17 -Wall -Wextra -Werror -g -fsanitize=address,undefined prog.c -o prog
g++ -std=c++20 -Wall -Wextra -Werror -g -fsanitize=address,undefined prog.cpp -o prog
Some files are wrong on purpose: an agent draft with planted defects, a leaky version to run under Valgrind, a race for ThreadSanitizer to find. The chapter says which, and what the instrument should report. Predict before you run.
| Chapter | Files | |
|---|
| ch03 Control Flow, Functions, Recursion, and Counting Operations | 3 | ch03.zip |
| ch05 Arrays, Strings, and Matrices: n, n², n³ | 6 | ch05.zip |
| ch06 The Stack and the Heap: Dynamic Memory and Ownership | 5 | ch06.zip |
| ch07 Structs, Headers, and Multi-File Programs | 8 | ch07.zip |
| ch08 Growable Arrays and Linked Lists: The Cost of Growth | 3 | ch08.zip |
| ch09 Files, Bits, and Function Pointers: ADTs Behind a Header | 24 | ch09.zip |
| ch10 Complexity and Sorting: Your First Delegation | 15 | ch10.zip |
| ch11 Specify First: Abstract Data Types | 15 | ch11.zip |
| ch12 Moving to C++: Is It Really C++? | 14 | ch12.zip |
| ch14 Resource Ownership: RAII, the Rules of Zero, Three, and Five, and Smart Pointers | 10 | ch14.zip |
| ch15 Inheritance, Polymorphism, and Composition: Reviewing an Agent's Design | 11 | ch15.zip |
| ch16 Templates and the Standard Library | 7 | ch16.zip |
| ch17 Binary Search Trees | 16 | ch17.zip |
| ch18 Hash Tables, Exceptions, and the Search Study | 12 | ch18.zip |
| ch20 A First Look at Concurrency | 17 | ch20.zip |
Chapters 1, 2, 4, 13 and 19 work from listings in the text and the files of the chapters around them, so they have no folder of their own.