Printing with std.debug.print
Get text on screen and format values.
Printing with std.debug.print is a free Zig Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Zig Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Your Window into the Program
Printing text is how you see what your code is doing. Zig's quickest way to do that is std.debug.print. 🖨️
Reaching Into std
The dots in std.debug.print are a path: the std module contains debug, which contains the print function you are calling.
const std = @import("std");
std.debug.print("Hello\n", .{});Two Arguments, Always
print always takes two things: a format string and a tuple of values to fill into it. Even with no values, you pass an empty tuple.
The Empty Argument Tuple
That .{} is an empty tuple. When your text has no placeholders, you still supply it so the function signature is satisfied.
std.debug.print("No values here\n", .{});Placeholders Use Braces
Inside the format string, {} marks a spot to drop in a value. Each placeholder pulls the next item from your argument tuple in order.
std.debug.print("Score: {}\n", .{42});Passing Multiple Values
List several values in the tuple and they fill the placeholders left to right, making it easy to combine data in one line.
std.debug.print("{} plus {} is {}\n", .{2, 3, 5});Format Specifiers
Add a letter inside the braces to control output. For example {s} prints a string slice and {d} forces decimal integer formatting.
std.debug.print("Name: {s}\n", .{"Ada"});Newlines Are Manual
print does not add line breaks for you. Include the \n escape yourself whenever you want output to move to the next line.
It Writes to stderr
One key detail: std.debug.print sends text to stderr, the error stream. That is fine for learning and quick debugging output.
For Real Output, Use stdout
Serious programs print results to stdout via a writer. But debug.print stays the friendliest choice while you are exploring.
No Allocator Needed
A nice perk: std.debug.print needs no allocator. You can call it anywhere, even before you set up memory management.
Quick Check
You write std.debug.print("Hi\n", .{}). What is the role of the .{} part?
Recap
Use std.debug.print with a format string and an argument tuple. Fill {} placeholders, add \n yourself, and remember it writes to stderr. 🎯
Frequently asked questions
Is the “Printing with std.debug.print” lesson free?
Yes — the full text of “Printing with std.debug.print” is free to read here on the web, and the Zig Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Zig Academy course, upgrade to CoddyKit PRO.
What will I learn in “Printing with std.debug.print”?
Get text on screen and format values. You practise Zig Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Zig Academy?
No prior experience is required. Zig Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Printing with std.debug.print” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Zig Academy lesson?
Yes. Every Zig Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Install Zig on Any Platform
- Your First main Function
- Printing with std.debug.print
- Compile and Run in One Step