Writes, Syscalls, and Buffering

I got it:

    var o = std.io.getStdOut();
    var bw = std.io.bufferedWriter(o.writer());
    var os = bw.writer();

    var buf: [1024]u8 = undefined;
    var cnt: u32 = 0;
    while (try is.readUntilDelimiterOrEof(&buf, '\n')) |line| {
        cnt += 1;
        if (cnt == ln) continue;
        std.debug.print("line #{}\n", .{cnt});
        // _ = try os.write(buf[0..line.len]);
        // _ = try os.write(line[0..]);
        _ = try os.write(line);
        _ = try os.write("\n");
    }
    try bw.flush();

works fine.

But it’s a bit brain out for me, I’d expect all ops to be available in the result of std.io.getStdOut();

1 Like