Notes / C / Pointers

Pointers in C — Revision Notes

A quick-reference cheat sheet: definition, syntax, example, common mistakes and an interview tip.

intermediate 📖 2 min revision

Definition

📌 Pointers A pointer is a variable that stores the memory address of another variable, instead of a value directly.

Syntax

syntax
type *pointerName;
pointerName = &variable;
*pointerName;   // dereference: get the value

Example

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;
}

Output

outputValue: 25 Address: 0x7ffee2a3c9ac Via pointer: 25

Important Points

Common Mistakes

Interview Tip

🎯 Before your interview Be ready to explain pointer arithmetic: incrementing a pointer moves it forward by sizeof(type) bytes, not just 1 byte.
Back to notes Read full lesson →