Back to course

Hello World and Build System

Full Course: Zig Programming From Zero to Hero

Hello World in Zig

Let's write your first program. Create a file named main.zig.

zig const std = @import("std");

pub fn main() !void { const stdout = std.io.getStdOut().writer(); try stdout.print("Hello, {s}!\n", .{"World"}); }

Running the code

Use the command: zig run main.zig.

The Build System

Zig comes with a built-in build system. Run zig init-exe to create a project template including a build.zig file, which allows you to compile your code for different platforms easily.