Reading Files and stdin
Stream input into your program.
Tools Consume Input
A useful CLI usually reads something: a file you name, or text piped into it. Zig gives you clear, explicit ways to do both. 📥
Open a File by Path
Use std.fs.cwd to get the current directory, then openFile to open a path relative to it for reading.
const file = try std.fs.cwd().openFile(path, .{});All lessons in this course
- Reading Command-Line Arguments
- Reading Files and stdin
- Writing Output and Exit Codes
- Package and Release the Binary