Strings In Depth12 / 19
Up next

Format into a stack buffer

const std = @import("std");

pub fn main() !void {
    var buf: [32]u8 = undefined;
    // bufPrint writes into buf and returns the used slice
    const msg = try std.fmt.bufPrint(&buf, "item #{d}", .{7});
    std.debug.print("{s}\n", .{msg});
}
What you're solving

std.fmt.bufPrint needs no allocator