liveBook · Manning

What you will learn in Modern C, Third Edition

Covers the C23 standard

by Jens Gustedt

Chapter by chapter

Chapter 1: Getting started

This introduction frames C programming as giving a computer instructions to carry out specific tasks.

1.1 Imperative programming · 1.2 Compiling and running · 1.3 Summary

What you learn in chapter 1 →

Chapter 2: The principal structure of a program

The introduction connects earlier C examples to larger programs and distinguishes a program’s syntax from its semantic parts.

2.1 Grammar · 2.2 Declarations · 2.3 Definitions · 2.4 Statements · 2.4.1 Iteration · 2.4.2 Function calls · 2.4.3 Function return · 2.5 Summary

What you learn in chapter 2 →

Chapter 3: Everything is about control

This introduction contrasts unconditional function calls and returns with conditional control statements, then identifies the roles of C’s five conditional statements.

3.1 Conditional execution · 3.2 Iterations · 3.3 Multiple selection · 3.4 Summary

What you learn in chapter 3 →

Chapter 4: Expressing computations

Introduces C expressions as code that computes values and distinguishes arithmetic expressions from comparisons.

4.1 Operands and operators · 4.2 Arithmetic · 4.2.1 +, -, and * · 4.2.2 Division and remainder · 4.3 Operators that modify objects · 4.4 Boolean context · 4.4.1 Comparison · 4.4.2 Logic · 4.5 The ternary or conditional operator · 4.6 Evaluation order · 4.7 Summary

What you learn in chapter 4 →

Chapter 5: Basic values and data

The chapter introduces the distinction between C values and their representations, and presents the abstract state machine as a platform-independent way to reason about program state.

5.1 The abstract state machine · 5.1.1 Values · 5.1.2 Types · 5.1.3 Binary representation and the abstract state machine · 5.1.4 Optimization · 5.2 Basic types · 5.3 Specifying values · 5.3.1 Complex constants · 5.4 Implicit conversions · 5.5 Initializers · 5.6 Named constants · 5.6.1 Read-only objects · 5.6.2 Enumerations · 5.6.3 Macros · 5.6.4 Compound literals · 5.6.5 The constexpr construct · 5.7 Binary representations · 5.7.1 Unsigned integers · 5.7.2 Bit sets and bitwise operators · 5.7.3 Shift operators · 5.7.4 Boolean values · 5.7.5 Signed integers · 5.7.6 Fixed-width integer types · 5.7.7 Bit-precise integer types · 5.7.8 Floating-point data · 5.8 Summary

What you learn in chapter 5 →

Chapter 6: Derived data types

Introduces four ways C derives data types from basic types and distinguishes them from typedef, which gives an existing type a new name.

6.1 Arrays · 6.1.1 Array declaration · 6.1.2 Array operations · 6.1.3 Array length · 6.1.4 Arrays as parameters · 6.1.5 Strings are special · 6.2 Pointers as opaque types · 6.3 Structures · 6.3.1 Simple structures to access fields by name · 6.3.2 Structures with fields of different types · 6.3.3 Nested structures · 6.3.4 Coalescing structure fields · 6.4 New names for types: Type aliases · 6.5 Summary

What you learn in chapter 6 →

Chapter 7: Functions

The chapter introduction contrasts conditional and unconditional control transfer and explains why functions are useful for organizing C programs.

7.1 Simple functions · 7.2 main is special · 7.3 Recursion · 7.4 Summary

What you learn in chapter 7 →

Chapter 8: C library functions

Introduces the C library as a portable set of everyday programming tools and explains how its specified API can separate compiler and library implementations.

8.1 General properties of the C library and its functions · 8.1.1 Headers · 8.1.2 Interfaces · 8.1.3 Error checking · 8.1.4 Bounds-checking interfaces · 8.1.5 Platform preconditions · 8.2 Integer arithmetic · 8.3 Numerics · 8.4 Input, output, and file manipulation · 8.4.1 Unformatted text output · 8.4.2 Files and streams · 8.4.3 Text I/O · 8.4.4 Formatted output · 8.4.5 Unformatted text input · 8.5 String processing and conversion · 8.5.1 Portability of string processing · 8.6 Time · 8.7 Runtime environment settings · 8.8 Program termination and assertions · 8.9 Summary

What you learn in chapter 8 →

Chapter 9: Style

The chapter introduces readability as a requirement for C code and explains how human limits and project culture shape coding style.

9.1 Formatting · 9.2 Naming · 9.3 Internationalization, so to speak · 9.4 Summary

What you learn in chapter 9 →

Chapter 10: Organization and documentation

This introduction explains why useful documentation distinguishes an interface’s purpose from its implementation details and why code and comments should each contribute meaningful information.

10.1 Interface documentation · 10.2 Implementation · 10.2.1 Macros · 10.2.2 Pure functions · 10.2.3 Attributes · 10.3 Summary

What you learn in chapter 10 →

Chapter 11: Pointers

The chapter introduces pointers as references to other objects and shows how they let a function change objects belonging to its caller.

11.1 Pointer operations · 11.1.1 Address-of and object-of operators · 11.1.2 Pointer addition · 11.1.3 Pointer subtraction and difference · 11.1.4 Pointer validity · 11.1.5 Null pointers · 11.2 Pointers and structures · 11.3 Pointers and arrays · 11.3.1 Array and pointer access are the same · 11.3.2 Array and pointer parameters are the same · 11.4 Function pointers · 11.5 Summary

What you learn in chapter 11 →

Chapter 12: The C memory model

Introduces the C memory model as an abstraction for accessing objects through pointers, while establishing the roles of pointer types and byte-based object representations.

12.1 A uniform memory model · 12.2 Unions · 12.3 Memory and state · 12.4 Pointers to unspecific objects · 12.5 Explicit conversions · 12.6 Effective types · 12.7 Alignment · 12.8 Summary

What you learn in chapter 12 →

Chapter 13: Storage

The introduction contrasts the lifetimes of previously encountered objects with storage instances created by recursive calls and dynamic allocation.

13.1 malloc and friends · 13.1.1 A complete example with varying array size · 13.1.2 Ensuring consistency of dynamic allocations · 13.1.3 Flexible array members · 13.2 Storage duration, lifetime, and visibility · 13.2.1 Static storage duration · 13.2.2 Automatic storage duration · 13.3 Digression: Using objects before their definition · 13.4 Initialization · 13.5 Digression: A machine model · 13.6 Summary

What you learn in chapter 13 →

Chapter 14: More involved processing and I/O

The introduction connects the chapter’s text-processing and formatted-input topics to the pointer concepts covered earlier.

14.1 Text processing · 14.2 Formatted input · 14.3 Extended character sets · 14.4 UTF character encodings · 14.5 Restartable text conversion · 14.6 Binary streams · 14.7 Summary

What you learn in chapter 14 →

Chapter 15: Program failure

The introduction frames program failure around its causes, sketches three ways failures arise, and limits the chapter’s scope to failures that manifest during execution.

15.1 Wrongdoings · 15.1.1 Arithmetic violations · 15.1.2 Invalid conversions · 15.1.3 Value violations · 15.1.4 Type violations · 15.1.5 Access violations · 15.1.6 Value misinterpretation · 15.1.7 Explicit invalidation · 15.2 Program state degradation · 15.2.1 Unbounded recursion · 15.2.2 Storage exhaustion · 15.2.3 Other scarce resources · 15.3 Unfortunate incidents · 15.3.1 Escalating state degradation · 15.3.2 Collisions and race conditions · 15.3.3 Inappropriate library calls and macro invocations · 15.3.4 Deadlocks · 15.4 Series of unfortunate events · 15.5 Dealing with failures · 15.6 Error checking and cleanup · 15.7 Summary

What you learn in chapter 15 →

Chapter 16: Performance

The chapter introduction argues for safe, relevant performance work and explains how programmers can give C compilers useful optimization information.

16.1 Inline functions · 16.2 Using restrict qualifiers · 16.3 Unsequenced and reproducible attributes · 16.4 Measurement and inspection · 16.5 Summary

What you learn in chapter 16 →

Chapter 17: Function-like macros

The chapter introduction explains why inline functions are usually safer than function-like macros, while identifying when macros remain useful.

17.1 How function-like macros work · 17.2 Argument checking · 17.3 Accessing the context of invocation · 17.4 Variable-length argument lists · 17.4.1 Variadic macros · 17.4.2 A detour: Variadic functions · 17.5 Default arguments · 17.6 Summary

What you learn in chapter 17 →

Chapter 18: Type-generic programming

The introduction shows that C already has widespread type-generic features, then contrasts the fixed-type limits of _Generic with C23 type inference.

18.1 Inherent type-generic features in C · 18.1.1 Operators · 18.1.2 Default promotions and conversions · 18.1.3 Macros · 18.1.4 Variadic functions · 18.1.5 Function pointers · 18.1.6 void pointers · 18.1.7 Type-generic C library functions · 18.2 Generic selection · 18.3 Type inference · 18.3.1 The auto feature · 18.3.2 The typeof feature · 18.4 Anonymous functions · 18.5 Summary

What you learn in chapter 18 →

Chapter 19: Variations in control flow

Introduces basic blocks and structured control flow, then explains why less predictable changes in control flow make program state harder to reason about.

19.1 A detailed example · 19.2 Sequencing · 19.3 Short jumps · 19.4 Functions · 19.5 Long jumps · 19.6 Signal handlers · 19.7 Summary

What you learn in chapter 19 →

Chapter 20: Threads

Introduces threads as concurrent control flows through the B9 game, then shows how C starts, runs, and joins its task threads.

20.1 Simple interthread control · 20.2 Race-free initialization and destruction · 20.3 Thread-local data · 20.4 Critical data and critical sections · 20.5 Communicating through condition variables · 20.6 More sophisticated thread management · 20.7 Ensure liveness · 20.8 Summary

What you learn in chapter 20 →

Chapter 21: Atomic access and memory consistency

The introduction frames memory consistency in terms of concurrent access, effects on a program’s abstract state, and the limits of a single timeline across threads.

21.1 The “happened-before” relation · 21.2 C library calls that provide synchronization · 21.3 Sequential consistency · 21.4 Other consistency models · 21.5 Summary

What you learn in chapter 21 →

Chapter 22: Technical annex

This introduction explains when C23 toolchain support or differences from the author’s development environment may limit the annex’s usefulness.

What you learn in chapter 22 →

Concepts explained in this book

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.