Input fixes
This commit is contained in:
@@ -37,12 +37,13 @@ fn getInput(message: []const u8) !usize {
|
|||||||
var line_buffer: [100]u8 = undefined;
|
var line_buffer: [100]u8 = undefined;
|
||||||
var w: std.io.Writer = .fixed(&line_buffer);
|
var w: std.io.Writer = .fixed(&line_buffer);
|
||||||
|
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
w.end = 0;
|
||||||
try output.writeAll(message);
|
try output.writeAll(message);
|
||||||
try output.flush();
|
try output.flush();
|
||||||
|
|
||||||
const line_length = try stdin.interface.streamDelimiterLimit(&w, '\n', .unlimited);
|
const line_length = try stdin.interface.streamDelimiterLimit(&w, '\n', .unlimited);
|
||||||
|
stdin.interface.toss(1);
|
||||||
const input_line = line_buffer[0..line_length];
|
const input_line = line_buffer[0..line_length];
|
||||||
|
|
||||||
const res = std.fmt.parseInt(usize, input_line, 10) catch {
|
const res = std.fmt.parseInt(usize, input_line, 10) catch {
|
||||||
|
|||||||
Reference in New Issue
Block a user