Values & References18 / 18
Up next

Sentinel-terminated pointers

const std = @import("std");

pub fn main() void {
    // a C-style string is a pointer terminated by a 0 byte
    const cstr: [*:0]const u8 = "hello";
    // std.mem.span walks to the sentinel to build a slice
    const s = std.mem.span(cstr);
    std.debug.print("{s} len {d}\n", .{ s, s.len });
}
What you're solving

[*:0]T marks a terminator value