0PricingLogin
Zig Academy · Lesson

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

  1. Strings Are []const u8
  2. String Literals and Escapes
  3. Comparing and Searching Bytes
  4. Formatting Text with std.fmt
← Back to Zig Academy