Skip to content

Instantly share code, notes, and snippets.

@lmllrjr
Created October 16, 2023 21:19
Show Gist options
  • Save lmllrjr/76ec548de1f4c15097d56032f93b52ca to your computer and use it in GitHub Desktop.
Save lmllrjr/76ec548de1f4c15097d56032f93b52ca to your computer and use it in GitHub Desktop.
⚡️ zig get command line arguments
const std = @import("std");
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
const args = try std.process.argsAlloc(allocator);
defer std.process.argsFree(allocator, args);
std.debug.print("Arguments: {s}\n", .{args[1..2]});
std.debug.print("Arguments2: {any}\n", .{std.os.argv});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment