Printing Zig Structs (opens in new tab)

Discussed on Lobsters

I recently found a new way to print formatted strings in Zig. If you’ve spent much time with the language, you’ve probably tried to print something to a console or other output. Here’s an example of what that can look like in Zig 0.16.0: const std = @import("std"); pub fn main(init: std.process.Init) !void { const io = init.io; const stdout_handle = std.Io.File.stdout(); var buf: [128]u8 = undefined; var stdout = stdout_handle.writer(io, &buf); const time = "afternoon"; const name = "Edward";...

Read the original article
Sign in to keep reading the full article.

Keyboard Shortcuts

Navigation

Next / previous post
j/k
Open post
oorEnter
Preview post
v

Post Actions

Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Save / unsave
s

Recommendations

Add interest / feed
Enter
Not interested
x

Go to

Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Discover
gb
Search
/

General

Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help