Strings Are []const u8
Why Zig strings are byte slices.
No String Type
Zig has no dedicated string type. A piece of text is simply a slice of bytes, so you reuse the same tools you already know for arrays. 📦
It Is Just Bytes
A Zig string is the type []const u8: a read-only window over a run of 8-bit bytes. Each byte holds one number from 0 to 255.
const greeting: []const u8 = "hello";All lessons in this course
- Strings Are []const u8
- String Literals and Escapes
- Comparing and Searching Bytes
- Formatting Text with std.fmt