Pointer

A variable that stores the memory address of another variable.

Fundamental to performance-critical systems and operating system design. Many higher-level languages (like Java or Python) use 'References' which are abstracted pointers.

        graph LR
  Center["Pointer"]:::main
  Pre_variable["variable"]:::pre --> Center
  click Pre_variable "/terms/variable"
  Rel_linked_list["linked-list"]:::related -.-> Center
  click Rel_linked_list "/terms/linked-list"
  Rel_stored_program_concept["stored-program-concept"]:::related -.-> Center
  click Rel_stored_program_concept "/terms/stored-program-concept"
  classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
  classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
  classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
  classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
  linkStyle default stroke:#4b5563,stroke-width:2px;

      

🧒 Explain Like I'm 5

🌍 Imagine a treasure map. The map itself isn't the gold; it just has an 'X' that tells you where the gold is buried. In programming, a pointer is like that map—it points to the exact house and room where your data is living.

🤓 Expert Deep Dive

Pointers are a fundamental feature of low-level languages like C and C++. They provide direct hardware access and are used for dynamic memory allocation, efficient data structure implementation (e.g., Linked Lists, Trees), and zero-copy data passing. Key operations include Dereferencing (*p in C), which retrieves the value at the address, and Address-of (&x), which retrieves the address of a variable. Modern systems utilize Smart Pointers (such as std::unique_ptr in C++ or References in Rust) to manage memory safety and prevent leaks. Issues like Segmentation Faults occur when a pointer attempts to access a memory region it does not have permission for, whereas Pointer Arithmetic allows for iterating through contiguous memory blocks (arrays).

🔗 Related Terms

Prerequisites:

📚 Sources