$ drills
Drill 0: Global vs Local Variables
// TODO: Print the addresses of a local variable, a global variable,
// and a function (like main). Compare them.
Drill 1: Basic Address & Dereference
// TODO: Declare an int, a pointer to it,
// print its value, address, and dereferenced value.
// HINT: Use & to take the address, * to dereference.
Drill 2: Swap Two Ints
// TODO: Write a function swap(int *a, int *b)
// that swaps two integers.
// HINT: You'll need a temporary variable.
Drill 3: Array Decay & Pointer Arithmetic
// TODO: Create an array.
// Show that arr == &arr[0].
// Use *(arr + 1) to access the 2nd element.
Drill 4: Structs & the -> Operator
// TODO: Define a struct (Character).
// Create a pointer to it.
// Use -> to access one of its members.
Drill 5: Stack Frame Addresses
// TODO: Write a function with a local int.
// Print its address.
// Call the function multiple times and compare addresses.
💡 Stuck? View the solutions.