Learn C Programming

Lesson 2 of 10 · Pointers and Memory

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

  1. A pointer is a variable that holds an address
  2. The star follows the pointer to its target
  3. One star, two jobs
  4. NULL: a pointer that points at nothing
  5. What following NULL does on the Playground
  6. Bob's 5 and the wild pointer
  7. The type rule: an int pointer points at an int
  8. Pointing somewhere else