liveBook · Manning

Pointer arithmetic

Pointer arithmetic computes pointer values by applying offsets relative to pointed-to elements or by finding differences between related pointers.

How 3 Manning books explain it

Modern C, Third Edition

Pointer arithmetic is the C operation of forming pointer values by adding or subtracting integer offsets relative to elements of an array object.

How it is used
Uses pointer offsets to traverse array elements and express positions or stopping boundaries in pointer-based interfaces.
How deep it goes
Defines addition, subtraction, one-past boundaries, same-array requirements, and ptrdiff_t, while deferring broader pointer mechanics.
Examples
Demonstrates forward and reverse summation, one-based subarray starts, infinite-element diagnostics, and same-array pointer differences.
What you can do after
Apply it to traverse arrays, calculate element distances, and diagnose invalid pointer relationships without confusing pointers with arrays.

Read how Modern C, Third Edition explains pointer arithmetic →

100 C++ Mistakes and How to Avoid Them

Pointer arithmetic is the calculation of pointer values by adding or subtracting element-based offsets.

How it is used
Explains why generic base-pointer functions cannot safely process arrays of derived objects.
How deep it goes
Traces indexing to byte offsets and demonstrates incorrect reads and destruction, then stops at a type-preserving template correction.
Examples
Uses integer indexing, base and derived classes, printed output, array deletion, and a type-preserving template rewrite.
What you can do after
Diagnose array bugs caused by base-sized pointer steps and preserve element types when writing array-processing functions.

Read how 100 C++ Mistakes and How to Avoid Them explains pointer arithmetic →

Modern C

Pointer arithmetic is the C operation of adding or subtracting an integer offset from a pointer or computing the difference between pointers into the same array.

How it is used
Uses pointer arithmetic to traverse arrays and express subarray interfaces in C functions.
How deep it goes
Explains addition, subtraction, difference types, bounds, one-past pointers, and dereference restrictions through worked loops.
Examples
Demonstrates forward and reverse summation, subarray calls, one-past dereferencing errors, and same-array pointer differences.
What you can do after
Apply it to implement forward, reverse, and subarray traversals while preserving lengths and avoiding invalid pointer operations.

Read how Modern C explains pointer arithmetic →

Related concepts

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.