viernes, 18 de octubre de 2024

how to convert an integer to string in Zig

I have been spending a while on learning Zig, by the way is pretty amazing.

fn convert_to_string(value: u32) []const u8 {
    var buffer: [4096]u8 = undefined;
    const result = std.fmt.bufPrintZ(buffer[0..], "{d}", .{value}) catch unreachable;
    return @as([]const u8, result);
}

No hay comentarios:

Publicar un comentario