Module 11 · Pointers and Memory
Pointers: a Variable That Holds an Address
Free with an accountReading
Bob has finished lesson 01, so he knows that a pointer holds an address. He writes two lines he has seen in other people's C: int *p; and then *p = 5;. The Playground answers Runtime error and prints nothing. "Where did the 5 go?" he asks. By the end of this lesson you can tell him.
Checking what this lesson needs for you…
What is inside Pointers: a Variable That Holds an Address
- A pointer is a variable that holds an address
- The star follows the pointer to its target
- One star, two jobs
- NULL: a pointer that points at nothing
- What following NULL does on the Playground
- Bob's 5 and the wild pointer
- The type rule: an int pointer points at an int
- Pointing somewhere else