Beginner · 20 minYou are hereRead
Pointers and addresses
A pointer is a box that holds an address. The operator & takes the address of a variable, and * follows a pointer to the box it names.
C and memory
Beginner · 20 minYou are hereRead
A pointer is a box that holds an address. The operator & takes the address of a variable, and * follows a pointer to the box it names.
Intermediate · 25 minYou are hereRead
A function given an address can change the caller’s variables. It gets a copy of the address, and every write through it lands in the caller’s box.
Intermediate · 25 minYou are hereRead
An array is a row of equal boxes side by side. a[i] is the box i steps from the start, and adding 1 to a pointer moves it on by one element’s size.
Intermediate · 25 minYou are hereRead
Memory from malloc lives on the heap until free gives it back, so it outlives the function that asked for it. The stack keeps a variable only for its call.
Intermediate · 25 minYou are hereRead
C does not check how memory is used. A leak, a use after free, an uninitialised read or a read past the end runs to the end unless a tool catches it.
Related topics