Preface
- Part I. First Contact
Chapter 1. Why C Still Matters
- C as a Portable Assembly
- C and the Shape of Modern Software
- What You Can Build with C
- The Limits of C — and Why They Matter
Chapter 2. Setting Up the Environment
- Choosing a Compiler
- Command-Line Compilation
- Understanding the Build Process
- Your First C Program
- A Lightweight IDE for C: Geany
- How to Read Compiler Errors
Chapter 3. A First Mental Model
- Programs as Memory and Instructions
- Variables as Named Memory
- Statements as Steps in Time
- Part II. Core Language Foundations
Chapter 4. Basic Types and Values
- Integer Types and Their Ranges
- Floating-Point Reality
- Characters and Text
- Type Conversion Rules
Chapter 5. Expressions and Operators
- Expressions as Computations
- The Operator Landscape in C
- Increment and Decrement Operators
- Operator Precedence and Clarity
- Side Effects and Sequence Points
- The Ternary Operator (
?:) - Writing Predictable Expressions
Chapter 6. Control Flow
- Branching with
ifandswitch - Looping with
whileandfor - The
do-whileLoop - Breaking and Continuing
- Structured Thinking in C
Chapter 7. Functions and Program Structure
- Functions as Units of Work
- Void Functions
- Parameters and Return Values
- Local Scope and Lifetime
- Organizing Multi-File Programs
- Part III. Memory and Data Representation
Chapter 8. Arrays and Strings
- Contiguous Memory
- Indexing and Bounds
- Strings as Character Arrays
- Common String Operations
- Common String Pitfalls
Chapter 9. Pointers and Addresses
- Memory Addresses as Values
- Pointer Types and Arithmetic
- Pointers and Arrays — The Deep Relationship
- Reading Pointer Declarations
- When and Why to Use Pointers
- Common Pointer Pitfalls
Chapter 10. Lifetime and Storage Duration
- Automatic Storage
- Static Storage
- Dynamic Allocation
- Why Lifetime Matters
Chapter 11. Dynamic Memory
mallocandfree- Ownership of Allocated Memory
- Memory Leaks and Dangling Pointers
- Patterns for Safe Allocation
- Part IV. Structuring Data
Chapter 12. Structures
- Grouping Related Data
- Defining and Using struct
- Structures and Memory Layout
- Passing Structures to Functions
- Best Practices for Using Structures
Chapter 13. Unions and Bit-Level Representation
- Overlapping Storage
- When Unions Make Sense
- Bit Fields
- Low-Level Data Modeling
Chapter 14. Enumerations and Symbolic Meaning
- Named Integer Sets
- Enums for Readable Code
- Enums and Type Safety
- Part V. Working with the Outside World
Chapter 15. Input and Output
- Standard Streams
- Formatted Output
- Reading Input Safely
- File Streams
Chapter 16. Files and Persistence
- Opening and Closing Files
- Binary vs Text Files
- File Positioning
- Practical File Patterns
Chapter 17. The C Standard Library
- Headers and Interfaces
- String and Memory Utilities
- Mathematical Functions
- Error Reporting
- Part VI. The Preprocessor and Build Model
Chapter 18. The Preprocessor
- Macro Expansion Model
- Object-like and Function-like Macros
- Header Files and Include Guards
- When Not to Use Macros
Chapter 19. Separate Compilation
- Translation Units
- Header Design Principles
- Linking Multiple Files
- Managing Interfaces
- Part VII. Writing Robust C
Chapter 20. Undefined Behavior and Defensive Programming
- What Undefined Behavior Really Means
- Common Sources of Undefined Behavior
- Writing Predictable Programs
Chapter 21. Error Handling Strategies
- Return Codes
errno- Designing Error-Conscious APIs
Chapter 22. Testing and Debugging
- Using a Debugger
- Assertions
- Building Small Test Programs
- Part VIII. Thinking in C
Chapter 23. Performance and Cost Models
- What C Gives You
- Constant-Time Thinking
- Memory Access Patterns
Chapter 24. Abstraction in a Low-Level Language
- Abstraction Without Classes
- Opaque Structs
- Designing Clean Interfaces