0Pricing
Zig Academy · Lesson

Dereferencing with ptr.*

Read and write through a pointer.

Reaching the Value

A pointer holds an address, not a value. To use the value behind it you must dereference the pointer first.

The .* Syntax

Zig dereferences with a trailing .* on the pointer. So ptr.* means the value that ptr currently points to.

var x: i32 = 7;
const p = &x;
const v = p.*;

All lessons in this course

  1. Single-Item Pointers with *T
  2. Dereferencing with ptr.*
  3. Many-Item Pointers [*]T
  4. Const Pointers and Alignment
← Back to Zig Academy