Zig by Example
Zig by Example
Zig is a general-purpose programming language and toolchain for maintaining robust, optimal and reusable software. Please read the official documentation to learn more.
Zig by Example is a hands-on introduction to Zig using annotated example programs.
The examples are written for version 0.16. Check which version you’re using if something isn’t working.
Getting Started
Hello, World!
Formatted Output
Unit Tests
Basic Types
Variables
Illegal Behavior
Build Modes
Basic Types
Integers
Integer Operators
Floating-point Numbers
Functions and Errors
Functions
Errors
Assertions
Control Flow
If Statements
Switch Statements
While Loops
For Loops
Blocks
Defer
Errdefer
Compound Types
Arrays
Slices
Pointers
Optionals
Structs
Tuples
Enums
Unions
Tagged Unions
Standard Library
Allocators
ArrayList
AutoHashMap
StringHashMap
HashMap
Sorting
Random
Command-line Programs
Arguments
Environment Variables
Exit Status
Async/Await and I/O
Async
Io Implementations
Queue
File System
Text I/O
Binary I/O
Comptime
Comptime
Precomputed Data
Generic Functions
Generic Types
Reflection
Zig Tooling
Build System
Zig and C
Using C
C Types
Time and Date
Zig by Example<br>·<br>about<br>·<br>source