We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

Pointers

You've probably heard of pointers. You may have also seen jokes about how they are impossible to learn... Well, that's wrong.

In fact, now that you understand how memory is laid out in an array, a lot of the mystery behind pointers should be gone. Put simply: a pointer is just a variable that stores a memory address. It's called a pointer, because it "points" to the address of a variable, which stores the actual data held in that variable.

Click to play video

Syntax

A pointer is declared with an asterisk (*) after the type. For example, int *.

int age = 37;
int *pointer_to_age = &age;

Remember, to get the address of a variable so that we can store it in a pointer variable, we can use the address-of operator (&).