Pointers
- Single-item pointers. A pointer type says its shape: one item, many items, sentinel-terminated: each distinct.
- Optional pointers. Nullable pointers are optionals: a pointer that may be null, its absence typed and dereference checked.
- Alignment in types. Pointer types carry alignment: the machine reality visible in the signature.
Slices
- Slices. A slice is a pointer plus length: []u8: the bounds-checked view Zig passes everywhere.
- Slicing arrays. Arrays slice with ranges: items[2..5]: views without copies.
- Sentinels. A sentinel-terminated slice ([:0]u8) speaks C-string: the boundary type for interop.
Memory Representation
- structs and layout. Zig structs lay out predictably: packed and extern variants pinning exact layouts.
- Endianness and bytes. Byte-level work is explicit: std.mem reading integers with named endianness.
- comptime-known sizes. @sizeOf and friends are compile-time answers: layout inspected as you design it.
Before and after this level
- Before: Level 1: Zig Foundations: Types and Values, Control Flow, Functions.
- Next: Level 3: Allocators: Explicit Allocation, Allocator Interfaces, Designing Memory Ownership.
In the app each of these ideas is taught and then asked back, and the level ends with a checkpoint and flashcards. See Checkpoints and flashcards.
Frequently asked questions
What does Zig Level 2: Pointers & Memory cover?
Pointers, Slices, Memory Representation: 3 lessons and 9 ideas.
What should I know before this level?
The level before it, Level 1: Zig Foundations, which covers Types and Values, Control Flow, Functions.