typestar

Pointers in C

Addresses and dereferencing: the heart of C.

int pointer_basics(void) {
    int value = 42;
    int *ptr = &value;

    int read = *ptr;
    *ptr = 100;

    int **handle = &ptr;
    int deep = **handle;
    return value + read + deep;
}

How it works

  1. &value takes the address; *ptr reads through it.
  2. Assigning *ptr writes back to the original.
  3. A pointer-to-pointer adds another level.

Keywords and builtins used here

The run, in numbers

Lines
11
Characters to type
164
Tokens
52
Three-star pace
90 tpm

At the three-star pace of 90 tokens a minute, this run takes about 35 seconds.

Type this snippet

Step 1 of 5 in Pointers, step 1 of 25 in Pointers & memory.

Next →

Pointers in other languages