Created
October 16, 2023 21:19
-
-
Save lmllrjr/76ec548de1f4c15097d56032f93b52ca to your computer and use it in GitHub Desktop.
⚡️ zig get command line arguments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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