Cheat sheets

PCC-13Cheat sheet1 pageIn a paid pack

Pointers: Arithmetic, const and Levels

The address and indirection operators, declarators such as int *p, q, a memory snapshot of an array, a pointer and a pointer to pointer, pointer arithmetic scaled by the element size, pointer subtraction and comparison rules, one past the end, the *p++ family traced on an array, const placement with its compile errors, and null, wild and dangling pointers.

Diagrams from PCC-13

PCC-14Cheat sheet1 pageIn a paid pack

void *, Function Pointers, Declarations

Rules for void pointers (implicit conversion, no dereference, no arithmetic in ISO C), the null pointer constant, function pointers (declaration, assignment, two call forms, arrays of function pointers, callbacks and a qsort comparator), typedef for function pointer types, and the inside-out method for reading declarations such as int (*a)[10], int *f(int) and int (*(*f)(int))[3].

PCC-18Cheat sheet1 pageIn a paid pack

Dynamic Memory and Linked Structures

malloc, calloc, realloc and free with their return values, the safe realloc idiom, memory leaks, double free, use after free, dangling pointers from returning a local and wild pointers, which defects are undefined behaviour, self-referential structures, inserting at the head of a linked list with a diagram, unlinking a node in the right order, reversing a list, and freeing a whole list.

Diagrams from PCC-18