Pointer
Variable that stores the memory address of another value, letting programs refer to data indirectly and build linked structures.
A pointer is a value that holds the location in memory of some other piece of data rather than the data itself. If a variable holds the number 42 at a particular address, a pointer to it holds that address, and following the pointer, called dereferencing, retrieves or changes the 42. Pointers let programs pass large structures to functions without copying them, allocate memory dynamically while running and build linked structures such as lists and trees, in which each element points to the next.
Pointers are most visible in C and C++, where programmers can take the address of a variable, perform arithmetic on addresses to move through arrays and convert between pointer types. This low-level control makes C well suited to operating systems, device drivers and embedded code, where software must manipulate memory and hardware directly. Most higher-level languages, including Java, Python and JavaScript, use references instead: these point to objects behind the scenes but do not expose raw addresses or allow arithmetic on them, and garbage collection manages the memory they refer to.
Misused pointers are a leading cause of serious software flaws. Dereferencing a null pointer typically crashes a program, and Tony Hoare, who introduced the null reference in 1965, later called it his billion-dollar mistake. Dangling pointers to freed memory, buffer overflows and use-after-free errors can corrupt data and are frequently exploitable as security vulnerabilities. Microsoft and the Chromium project have each reported that roughly 70 percent of their serious security bugs stem from memory-safety problems, which has driven interest in memory-safe languages such as Rust that check pointer use at compile time.
Key points
- A pointer stores a memory address, and dereferencing it reads or writes the value at that address.
- Pointers enable dynamic memory allocation and linked data structures such as lists and trees.
- Higher-level languages use references that hide raw addresses and forbid pointer arithmetic.
- Null dereferences, dangling pointers and buffer overflows are major sources of crashes and security vulnerabilities.
Related entries
C
General-purpose programming language created by Dennis Ritchie at Bell Labs in the early 1970s, foundational for operating systems and embedded software.
C++
General-purpose programming language created by Bjarne Stroustrup as an extension of C, combining low-level control with high-level abstractions.
Rust
Systems programming language that guarantees memory safety without a garbage collector through its ownership model, first stable in 2015.
Memory Leak
Bug in which a program keeps holding memory it no longer needs, so its memory use grows over time and can degrade or crash the system.
Garbage Collection
Automatic memory management in which a language runtime finds and reclaims memory occupied by objects a program can no longer use.
Type Safety
Degree to which a programming language prevents type errors, in which a value is used as if it were a different, incompatible kind of data.
Data Structure
Way of organizing and storing data in a computer so that it can be accessed and modified efficiently, such as an array, list, tree or hash table.
Vulnerability
A weakness in software, hardware, configuration or process that an attacker could exploit to compromise confidentiality, integrity or availability.