Skip to main content

Pointer

In Turkish
İşaretçi
Updated 3 min read

Share this page

Send the link, quote the definition with a link back, or show it as a card on your own site.

https://softwaredictionary.org/terms/pointer

In short

A pointer is a variable that stores the memory address of another value instead of the value itself, letting code read or change that data indirectly.

What is a pointer?

A pointer is a variable whose value is a memory address, the location where some other piece of data lives. Instead of holding the number 42, a pointer holds something like "the number stored at address 0x7ffd1234". Reading or writing the value at that address through the pointer is called dereferencing it.

Pointers are most visible in C, C++, Zig and Go. In C, &x gives the address of x, and *p follows the pointer p to the value it points to. Pointers make it possible to pass large structures to functions without copying them, to build linked data structures such as linked lists and trees, and to work with memory requested from the heap. C also allows pointer arithmetic: adding 1 to a pointer moves it to the next element of an array.

A pointer is like a street address written on a slip of paper: the slip is small and cheap to copy, and anyone holding it can find the house. The danger is that the address can be wrong. A null pointer points nowhere, and a dangling pointer still holds the address of memory that has already been freed, so following either one can crash the program or open a security hole. Languages such as Java, Python and JavaScript hide raw addresses behind references managed by the runtime, and Rust checks at compile time that its references always point to valid data.

A pointer is often confused with a reference. Both let code reach a value indirectly, but a pointer is an explicit address you can inspect, reassign, set to null and sometimes do arithmetic on, while a reference is a more restricted alias managed by the language. In C++, a reference must be bound to an object when it is created and can't be pointed elsewhere later, and in Java every object variable is a reference, but there is no way to see or change the address itself.

Key takeaways

  • A pointer stores a memory address rather than the data itself.
  • Dereferencing a pointer reads or writes the value at that address.
  • Pointers avoid copying large data and make linked data structures possible.
  • Null and dangling pointers are a common source of crashes and security bugs.
  • Many languages replace raw pointers with safer, runtime-managed references.

Example

Changing a value through a pointer in Cc
#include <stdio.h>

void double_it(int *n) {   // receives an address, not a copy
    *n = *n * 2;           // follow the pointer and change the original
}

int main(void) {
    int score = 21;
    int *p = &score;       // & takes the address of score
    double_it(p);
    printf("%d\n", score); // prints 42
    return 0;
}

Readers ask

What is a null pointer?

A null pointer deliberately points to no valid memory, usually written as NULL in C or nullptr in C++. Dereferencing it is an error that typically crashes the program, so code must check for null before using a pointer that might be empty.

Do Python and Java have pointers?

Not in the C sense. Variables that hold objects in Python and Java are references: the runtime tracks where each object lives, but you can't read the raw address, do pointer arithmetic or free the memory yourself.

What is the difference between a pointer and a reference?

A pointer is an explicit memory address that can be changed, compared and set to null. A reference is a safer, more limited way of referring to a value that the language manages for you.

See also

Spotted a mistake or something missing on this page?Suggest an edit

Read a random page
Open today's review
Switch to the dark theme
Read this page in Türkçe

More

Settings