Need to print a value, allocate memory, parse command-line arguments, or use a file? Zig’s standard library, std, supplies tools for these jobs. It is optional: you can replace its functionality with your own code, but its data structures and APIs are designed to be flexible and customizable. section 2.1 section 3.1
Import the std module with the compiler builtin @import and assign it to a constant. Dot syntax then reaches declarations inside its namespaces: std.debug.print names the print function in std.debug. section 2.1
Listing 2.1 A simple program
const std = @import("std"); #1
pub fn main() void { #2
const x: i32 = 42; #3
std.debug.print("{}\n", .{x}); #4
}
A minimal program imports std and uses std.debug.print to print an integer. section 2.1
The library also provides allocators and std.Io, which shape how Zig programs handle memory and I/O. For a larger project, standard-library networking can help turn a command-line word ladder game into a web application. section 3.1 section 4.2
Keep the standard-library documentation handy: run zig std to open it locally when network access is spotty. section 3.1







