zig_print


"/home/yossef/notes/courses/zig-course/zig_print.md"

path: courses/zig-course/zig_print.md

- **fileName**: zig_print
- **Created on**: 2026-02-08 18:52:35
const std = @import("std");
pub fn main() !void {
    const allocator = std.heap.page_allocator;
    // Prints to stderr, ignoring potential errors.
    const username = "yossef";
    const msg = try std.fmt.allocPrint( allocator, "i love my mom: {s}", .{username});
    std.debug.print("{s}\n", .{msg});
    std.log.info("welcome", .{});

    std.log.debug("welcome", .{});
    std.log.err("welcome", .{});
    std.log.warn("welcome", .{});
}

the format for the sting inside ""

Format Expected Data Type Example
{d} Integer (signed / unsigned) i32, u64
{s} String / Slice []const u8
{c} Single character u8
{b} Binary integers
{o} Octal integers
{x} Hexadecimal (lowercase) integers
{X} Hexadecimal (uppercase) integers
{e} Scientific notation f32, f64
{f} Floating point f32, f64
{any} Any type struct, enum, array

continue:[[]]
before:[[]]