Codiqo

Coding terms explained

What is a pointer?

In short

A pointer is a variable that holds the memory address of another value, so code can find and change that value where it lives.

Every value in a running program sits somewhere in the computer's memory, and every spot in memory has an address, like a house number. A normal variable holds a value; a pointer holds an address. Following the pointer to the value it points at is called dereferencing.

Pointers are a big part of C and C++. They let a function change a variable it was given, and they're how programs work with memory they ask for while running. Most other languages use them behind the scenes without showing you.

C

Change a value through a pointer

#include <stdio.h>

int main(void) {
    int score = 10;
    int *p = &score;
    *p = 25;
    printf("%d\n", score);
    return 0;
}

Output

25

Learn it properly

These free lessons teach it step by step, with questions and a program you write yourself.

Try your first lesson free

Codiqo teaches coding in five-minute lessons with real code. Free on the web, iPhone and Android.