Pointer to Pointer in C

Level 4121 keystrokes

Demonstrates double pointer (pointer to pointer) usage.

C code

// Regular integer variable
1int num = 100;
// Pointer to int, stores address of num
2int *ptr = #
// Pointer to pointer, stores address of ptr
3int **pptr = &ptr;
// Double dereference: *pptr is ptr, **pptr is num (100)
4printf("Value: %d\n", **pptr);
// Single dereference gives the address stored in ptr (differs on each run)
5printf("Address: %p\n", (void *)*pptr);

Output

Value: 100
Address: 0x7ffd12345678
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this C code and how often they appear.

  • *× 7
  • ;× 5
  • "× 4
  • (× 3
  • )× 3
  • =× 3
  • ,× 2
  • :× 2
  • \× 2
  • &× 2

More C examples at level 4

← C typing practice