I poke around memory addresses to see what’s happening with stack variables and heap allocations. No deep systems programming here, just me being curious.
main
sets up a number on the stack, grabs its address (the “base”).show
:- Prints the value.
- Shows the stack address where it lives.
- Calculates how far it is (in bytes) from the base address.
heap_example
:- Allocates a number on the heap using
Box
. - Turns it into a raw pointer.
- Prints the value and address (unsafe block because raw pointers are spicey).
- Allocates a number on the heap using