Buffering stores output bytes temporarily instead of sending each write to a file immediately. The runtime typically writes them all at once when a newline or byte-count threshold is reached; writing stored data is called flushing. Automatic buffering is implicit, while Zig lets programmers choose whether it happens and where the buffer memory comes from. section 1.6.2
Listing 1.2 All your codebase still belong to us
const std = @import("std");
pub fn main(init: std.process.Init) !void { #1
const io = init.io;
const stdout = std.Io.File.stdout(); #2
var stdout_buffer: [1024]u8 = undefined;
var stdout_writer = stdout.writer(io, &stdout_buffer); #3
const writer = &stdout_writer.interface; #3
try writer.print("All your codebase still belong to us!\n", .{}); #4
try writer.flush(); #5
}
The Zig example supplies a 1,024-byte buffer to a stdout writer, writes a newline-terminated message, and explicitly flushes it. section 1.6.2







