Hello,
this is my first forum post. Sorry if I’m missing some information, but i will try to provide them if necessary. So I started out with the new version of Zig 0.15.1, i created a simple Hello world application that prints to the Console output. I noticed however that when i create a Buffer of size [1024]u8, pass that buffer into the Writer and retrieve the std.Io.Writer interface that i can still print more than 1024 characters. I have created a Git repository with additional comments with some thoughts. I hope it’s okay to attach Links ![]()
https://codeberg.org/Kassiopeia/zig_print_stdout_0.15.1
In the main.zig file i have a function **fn print_bigger_than_buffer_size(w: *std.Io.Writer) void ** that prints the character a to stdout 2048 times. I also tried it with 1024 times, because maybe my math was (or is still) wrong. When i counted the characters after flushing the Writer the correct amount of Characters were outputted to the Console (i used an online character counting tool).
I tried looking through the std library documentation for version 0.15.1 but i couldn’t get behind it, the print function on std.Io.Writer didnt provide me any clues. I also tried to look into std.fs.File.writer and the only thing i could find was the description for it: Defaults to positional reading; falls back to streaming. so i thought it might be that the writer is using streaming?
Maybe someone can explain me what is going on behind the scenes, don’t get me wrong i like that i can print 2048 characters even though i only create a buffer of size 1024, but i want to understand how this is happening. Please keep in mind i just started Zig programming since version 0.15.0-dev came out so im very new. Also if someone has the time for it, they can check the comments i added in my source code and see if i got anything wrong and have to look into that topic again, thank you~ ![]()
edit: i suppose the buffer is not increased automatically, because that shouldn’t be possible right? So something else is going on, maybe the buffer is flushed when it reaches the max size (i cannot confirm this yet, i tried reading the source code but i have more questions than answers)? ![]()