Zig by Example: Hello World

To start, we’ll print the classic “Hello, World!” message.

const std = @import("std");
pub fn main() !void {
    std.debug.print("Hello, World!\n", .{});
}

To run this Zig program, use zig run.

$ zig run hello-world.zig
Hello, World!

To compile this Zig program, use zig build-exe.

$ zig build-exe hello-world.zig
$ ./hello-world
Hello, World!

Next example: Assignment.