A pointer is a variable that stores a memory address rather than a direct value. Instead of holding the number 42, a pointer holds the location where 42 lives in memory. That sounds abstract, but it is the foundation of how computers share data efficiently: pass the address and any code can find the original value without copying it. Pointers feel intimidating because the jargon is dense, but the core idea is just a signpost that says where to look.
The core idea
Every value your program creates lives somewhere in memory, and every location has a numeric address. A regular variable stores a value directly. A pointer stores one of those addresses.
A useful analogy: a value is a house, and a pointer is a slip of paper with the house number written on it. You can hand someone the paper (cheap, small) instead of the whole house, and they can still find their way there. If they change something inside, the change is real because there is only one house.
How pointers work
Two operations matter. Taking the address of a variable gives you a pointer to it. Dereferencing a pointer follows the address back to the value.
// C example: & takes an address, * follows one
int score = 42;
int *p = &score; // p now holds the address of score
*p = 100; // dereference: change the value at that address
// score is now 100, because p pointed at it
Because p pointed at score, writing through p changed score itself. That is the whole point: shared access to one piece of data.
Why pointers matter
| Use case |
What a pointer gives you |
| Large data |
Pass an address, avoid copying megabytes |
| Modifying arguments |
A function can change the caller original value |
| Data structures |
Linked lists and trees link nodes by address |
| Dynamic memory |
Track values created at runtime on the heap |
| Optional values |
A null pointer represents nothing here |
Without pointers, a function could only ever work on a copy. With them, code can collaborate on the same data.
Pointers across languages
You do not always see pointers, even when they are present.
- C and C++ expose raw pointers directly, including arithmetic.
- Go has pointers but no pointer arithmetic, which removes a whole class of bugs.
- Rust keeps pointers but adds ownership and borrowing rules the compiler checks.
- Python, Java, JavaScript hide pointers behind references. You never write
* or &, but when you pass an object, you are passing a reference under the hood.
This is why two Python variables can point at the same list and editing one appears to edit both: they reference the same object. Pointers also underpin a linked list in 2026, where each node holds the address of the next.
Common mistakes
- Dereferencing null. A null pointer points at nothing. Following it crashes the program. Check before you dereference.
- Dangling pointers. Keeping a pointer to memory that was already freed leads to unpredictable behavior. The address is valid, the data is not.
- Confusing the pointer with its target. Reassigning the pointer changes where it looks. Dereferencing and assigning changes the value it looks at. These are different.
- Leaking memory. In manual-memory languages, allocating without freeing wastes memory over time.
What to skip
- Pointer arithmetic until you are working with raw buffers or systems code. In most application work you never need it.
- Manual memory management by hand when your language offers smart pointers (C++
unique_ptr) or a garbage collector. Let the tooling track lifetimes.
- Casting pointers between unrelated types to save effort. It is a reliable source of corruption.
FAQ
Is a pointer the same as a reference?
Closely related but not identical. A reference is usually a safer, restricted alias that cannot be null or reseated, while a raw pointer can be null and reassigned. Languages like Java call their hidden pointers references.
What is a null pointer?
A pointer that deliberately points at no valid address, used to mean nothing here. Dereferencing it is a classic crash, so always check first.
Do I need pointers in Python or JavaScript?
Not explicitly. You never write pointer syntax, but objects are passed by reference, so the behavior of shared data still applies.
Why are pointers considered hard?
Because the bugs are invisible: a wrong address compiles fine and fails later, far from the cause. Tooling and stricter languages have made this much less painful.
Where to go next
See what a variable is in 2026, what an array is in 2026, and what a data structure is in 2026.