#how I can read input keyboard in zig help please and sorry for my English

1 messages · Page 1 of 1 (latest)

gusty flame
#

I find solutions work with zig 0.9 but in my pc I have a new version of zig I don’t have any idea how read input

gray forge
#

if we're just talking about a console program where it reads line by line, something like this should suffice:

var line_buffer = std.ArrayList(u8).init(allocator);
defer line_buffer.deinit();

const max_line_length = 1 << 21;
while (true) |line| {
    line_buffer.clearRetainingCapacity();
    try stdin.streamUntilDelimiter(line_buffer.writer(), '\n', max_line_length);
    const line = line_buffer.items;
}