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.
Sign in to read
This lesson is free, with an account
An account costs nothing and opens every lesson in this track that is not marked Pro, on every device you read on.
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