Imprimindo com std.debug.print
Exiba texto na tela e formate valores.
Imprimindo com std.debug.print é uma aula grátis de Zig Academy no CoddyKit. Esta é a aula 3 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de Zig Academy, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de Zig Academy inclui 4 aulas no total.
Partes desta aula ainda não foram traduzidas e aparecem em inglês.
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. 🎯
Perguntas Frequentes
A aula “Imprimindo com std.debug.print” é grátis?
Sim — o texto completo de “Imprimindo com std.debug.print” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de Zig Academy, atualize para CoddyKit PRO. O curso de Zig Academy inclui 4 aulas no total.
O que vou aprender em “Imprimindo com std.debug.print”?
Exiba texto na tela e formate valores. Você pratica Zig Academy com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.
Preciso ter experiência prévia para começar Zig Academy?
Nenhuma experiência prévia é necessária. Zig Academy no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 3 de 4.
Quanto tempo leva a aula “Imprimindo com std.debug.print”?
A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.
Posso escrever e executar código nesta aula de Zig Academy?
Sim. Cada aula de Zig Academy inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.
Todas as aulas deste curso
- Instale Zig em qualquer plataforma
- Sua primeira função main
- Imprimindo com std.debug.print
- Compile e execute em uma etapa