Home

pointers

Pointers are variables that store memory addresses rather than actual values. They enable indirect access to data, dynamic memory management, and the construction of data structures such as linked lists and trees. In low-level languages, a pointer's type indicates the type of value it can address, and the pointer itself occupies space that holds another address.

Common operations include obtaining the address of a variable, via the address-of operator, and dereferencing to

In languages like C and C++, pointers can reference any object, can be incremented or decremented, and

Safety concerns include dangling pointers (pointing to freed memory), memory leaks from unreleased allocations, and undefined

Many modern languages provide reference types that behave like pointers but with stronger safety guarantees, or

read
or
modify
the
pointed-to
value.
Pointer
arithmetic
allows
navigation
through
arrays
by
adding
or
subtracting
integer
offsets.
A
null
pointer
represents
the
absence
of
a
valid
address.
can
be
cast
between
types.
Function
pointers
store
addresses
of
functions
for
indirect
invocation.
Void
pointers
are
untyped
and
require
casting
to
a
concrete
type
before
use.
behavior
from
invalid
dereferencing.
Mitigations
include
disciplined
memory
management,
bounds
checking
where
provided,
and
language
features
such
as
smart
pointers
that
automate
lifetime
management.
restrict
direct
pointer
manipulation.
In
C++,
smart
pointers
such
as
unique_ptr
and
shared_ptr
help
manage
ownership,
while
languages
with
managed
runtimes
separate
memory
management
from
user
code.