3 ms·
The trick to teaching pointers is to model memory with boxes. You have a stack, and a heap, and you draw arrows to represent pointers. At some point, you need t
by acbart 10y ago
The trick to teaching pointers is to model memory with boxes. You have a stack, and a heap, and you draw arrows to represent pointers. At some point, you need to reveal that those arrows are just numeric indices, but the visual helps early on. The * and & operators just let you follow the value in the pointer. I've had a number of students who were baffled up until I showed them this model.
Notational Machine for the win!
- userbinator 10y agoIn general, thinking of memory as an array of bytes is helpful, and each byte has an address which is itself a series of bits that can be stored in memory --- and the concept that ties it all together and what I find makes a lot of people just "get it" is the fact that memory can itself store addresses that denote locations within it.
- Anthony-G 10y agoThat's a perfect example of how knowing some assembly code helps with learning C.
- stevekemp 10y agoBack in the 80s the programming books I used always showed memory as little lines of boxes. https://usborne.com/browse-books/features/computer-and-coding-books/ https://usborne.com/browse-books/features/computer-and-codin...