P-3.2 Pointers, and What They Are For
You can declare, dereference and pass pointers, explain pointer arithmetic in terms of element size, and say what a null and a dangling pointer are.
Pointers have a reputation they do not deserve, mostly earned by being taught as syntax rather than as an idea. A pointer is a variable holding an address, which you already know is a number, and every rule about them follows from that plus the size of the thing pointed at. The genuine difficulty is not the concept but the discipline: a pointer to storage that no longer exists looks exactly like a valid one.
Work through these
A pointer holds an address, and that is the whole idea
Taking the address of a variable gives you a number identifying where it lives, and dereferencing goes to that location to read or write. Everything else about pointers is consequence and notation.
CS50x: Introduction to Computer Science · CoursePassing an address so a function can change the caller's value
Since arguments are copied, handing over an address is how a function reaches back into its caller. This is the reason pointers appear in the first week rather than the last.
Pointer arithmetic moves by the size of the thing pointed at
Adding one to a pointer advances it by one element rather than one byte, which is why the type matters so much. Getting this wrong reads memory that belongs to something else.
Null pointers, and checking before you follow one
A null pointer deliberately points nowhere and is how functions report that they have nothing to return. Following one stops the program, which is the good outcome compared with the alternative.
Dangling pointers: an address that was valid a moment ago
When storage is released or a function returns, addresses into it become meaningless while continuing to look ordinary. Reading through one sometimes works, which is what makes it so hard to find.
Sign in to keep your progress.
Free resources
We haven't checked most of these for screen reader use yet.
Links last checked 31 Aug 2026.
Stuck here?
Ask a mentor. A real person answers, and they can see exactly which topic you're on. Usually within a couple of working days.
Checking your session…
Topics shown in module order.