A pointer is a variable whose value is the memory address of another piece of data. Instead of holding the data itself, it refers to where the data lives, and the program can follow the pointer to read or change it.
Why it matters
Pointers let programs share large data without copying it, build linked structures such as lists and trees, and work directly with memory in languages like C and C++. They are also a leading source of serious bugs. A pointer to freed memory (a dangling pointer), a null pointer that is dereferenced, or arithmetic that runs past the end of a buffer can crash a program or create security vulnerabilities. Many newer languages hide raw pointers behind references that the runtime keeps safe.
Example
int x = 10;
int *p = &x; // p holds the address of x
*p = 25; // write through the pointer
// x is now 25
&x takes the address of x, and *p follows the pointer to the value stored there.
Common mistakes
- Dereferencing a null or uninitialized pointer.
- Using a pointer after the memory was freed.
- Confusing the pointer with the thing it points to when copying (copying a pointer does not copy the data).
Related
Get notified when this term updates
Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.
यह पेज सामान्य जानकारी है, जिसे हमारी संपादकीय टीम ने लिखा है और दस्तावेज़ीकरण बदलने पर अपडेट किया जाता है। सर्वर और प्रदाता अलग-अलग होते हैं, इसलिए बदलाव पहले सुरक्षित तरीके से जाँचें। देखें: संपादकीय नीति और अस्वीकरण.