← Back to archive

Stdle #42 · structs · 2026-07-18

What does this Zig snippet output?

A past puzzle — fully playable. 4 attempts, hints on wrong guesses.

const std = @import("std");
const Flags = packed struct {
a: u1 = 1,
b: u1 = 0,
c: u1 = 1,
d: u1 = 1,
};
pub fn main() void {
const f = Flags{};
const byte: u4 = @bitCast(f);
std.debug.print("{d}\n", .{byte});
}
Structs
4 attempts left

Answer & explanation