String Literals and Escapes
Write and escape text safely.
Double-Quoted Literals
You write a string literal between double quotes. Zig stores its bytes in read-only memory and gives you a []const u8 slice pointing at them.
const msg = "Hello, Zig!";Escape Sequences
Inside a literal, a backslash starts an escape sequence. It lets you include characters that would otherwise be hard or impossible to type.
All lessons in this course
- Strings Are []const u8
- String Literals and Escapes
- Comparing and Searching Bytes
- Formatting Text with std.fmt