pointer

A variable that stores the memory address of another variable. Fundamental to C for arrays, dynamic memory, and pass-by-reference.

Syntax

c
type *ptrName;
ptrName = &variable;
*ptrName  // dereference

Example

c
int x = 42;
int *p = &x;         // p holds address of x
printf("%d\n", *p);  // 42 — dereference
*p = 100;            // modifies x through pointer
printf("%d\n", x);  // 100