authorgravatar for kappaloris@gmail.comLoris Cro <kappaloris@gmail.com> 2022-08-04 21:12:42+02:00
committergravatar for kappaloris@gmail.comLoris Cro <kappaloris@gmail.com> 2022-08-04 21:12:42+02:00
log616f65df750f53e6334cc5ed2c8f4b5668d573f2
tree687c451b525e6b0c039515414f64ab097a6fff2a
parentcbac7a019473055aaf6b1a87b4b57b9872ed54b4

init-exe template: add flushing to the buffered writer


1 files changed, 9 insertions(+), 7 deletions(-)

lib/init-exe/src/main.zig+9-7
......@@ -4,14 +4,16 @@ pub fn main() !void {
44 // Prints to stderr (it's a shortcut based on `std.io.getStdErr()`)
55 std.debug.print("All your {s} are belong to us.\n", .{"codebase"});
66
7 // Prints to stdout
8 const unbuffered_out = std.io.getStdOut().writer();
9 const out = std.io.bufferedWriter(unbuffered_out).writer();
10 try out.print("Run `zig build test` to run the tests.\n", .{});
11
12 // Stdout is for the actual output of your application, for example if you
7 // stdout is for the actual output of your application, for example if you
138 // are implementing gzip, then only the compressed bytes should be sent to
14 // stdout, not any debugging messages!
9 // stdout, not any debugging messages.
10 const stdout_file = std.io.getStdOut().writer();
11 var bw = std.io.bufferedWriter(stdout_file);
12 const stdout = bw.writer();
13
14 try stdout.print("Run `zig build test` to run the tests.\n", .{});
15
16 try bw.flush(); // don't forget to flush!
1517}
1618
1719test "simple test" {