Skip to content

Instantly share code, notes, and snippets.

@50n1cd347h9
Created August 31, 2024 21:14
Show Gist options
  • Save 50n1cd347h9/ed36a2fa4eae9384529d8db789caf991 to your computer and use it in GitHub Desktop.
Save 50n1cd347h9/ed36a2fa4eae9384529d8db789caf991 to your computer and use it in GitHub Desktop.
const std = @import("std");
const fmt = std.fmt;
const debugPrint = std.debug.print;

pub fn main() !void {
    const src = "hogehgoehgoe";
    const ch = 'A';
    var dst = [_]u8{0} ** 0x20;

    _ = try fmt.bufPrint(&dst, "{s}{c}{s}", .{
        src[0..3],
        ch,
        src[3..src.len],
    });

    debugPrint("/{s}/\n", .{dst});
}
s0n1cd347h9 src $ ./bufPrint
/hogAehgoehgoe/
@50n1cd347h9
Copy link
Author

a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment