Cheat sheets

PCC-15Cheat sheet1 pageIn a paid pack

Arrays, Decay and Row-Major Addresses

Array to pointer decay and its three exceptions, the identities a[i] = *(a + i) = i[a], partial initialisation, a versus &a versus &a[0], sizeof of arrays and of array parameters, two-dimensional arrays as arrays of rows with types and strides, row-major and column-major address formulas with lower bounds and computed examples, passing a 2-D array to a function, and the solved GATE CS 2019 Q.24.

Diagrams from PCC-15

PCC-16Cheat sheet1 pageIn a paid pack

Strings and the String Library

Strings as null-terminated character arrays, string literals versus modifiable char arrays, a byte picture of three ways to hold the same text, sizeof versus strlen including embedded null bytes, strlen, strcpy, strcat, strcmp, strncpy, strchr and strstr with their traps, pointer offsets into a literal, a hand-written length and reverse, and the undefined cases: modifying a literal and reading an array with no terminator.

Diagrams from PCC-16