Pointers
A pointer is a variable that stores the memory address of another variable, instead of a value directly. Pointers are what give C its famous low-level power — they let you access and modify memory directly, pass data efficiently to functions, and build dynamic data structures.
The & operator gets a variable's address, and * (dereferencing) gets the value stored at an address.
💡 Key insight
Pointers are the concept that separates "knows some C" from "understands C" in most interviews — take your time here.
Syntax
syntax
type *pointerName;
pointerName = &variable;
*pointerName; // dereference: get the valueExample
ptr stores the address of age; *ptr reads the value stored at that address.
c
#include <stdio.h>
int main() {
int age = 25;
int *ptr = &age;
printf("Value: %d\n", age);
printf("Address: %p\n", (void*)&age);
printf("Via pointer: %d\n", *ptr);
return 0;
}outputValue: 25
Address: 0x7ffee2a3c9ac
Via pointer: 25
Try it yourself
Copy this example into the C compiler and run it — try changing a value and see what happens.
