I am taking in input from stdin and then printing that out to stdout. However, on my laptop(amd64), only the end of the bytes are outputted, while on my android phone via Termux(arm64), it echos as expected.
Edit: Im compiling with zig version 0.16.0 on both
pub fn scanf(io: std.Io) ![]u8 {
var stdin_buffer: [1024]u8 = undefined;
var stdin_reader = std.Io.File.stdin().reader(io, &stdin_buffer);
const stdin = &stdin_reader.interface;
//setup reader
const line = try stdin.takeDelimiterExclusive('\n');
return line;
}
pub fn main(init: std.process.Init) !void {
print("My first Zig program {s}\n", .{"YAYY!"});
// print("gameboard {any}\n",.{gameboard});
const gameboard = Board.init(DBS);
display_board(DBS, gameboard);
const ng = Game.new();
print("{}\n\n\n\n", .{ng});
print("> ", .{});
var stdout_buffer: [1024]u8 = undefined;
var stdout_writer = std.Io.File.stdout().writer(init.io, &stdout_buffer);
const stdout = &stdout_writer.interface;
// _ = stdout;
const line = try scanf(init.io);
//print("{s}\n", .{line});
try stdout.print("{s}\n", .{line});
try stdout.flush();
}
amd64 output
Results
My first Zig program YAYY!
0 0 0 0 0
1 0 0 0 0
2 0 0 0 0
3 0 0 0 0
0 1 2 3
.{ .players = .{ .items = { }, .capacity = 0 }, .active_resource = .Brick }
> hello world
rld
arm64 output (Expected)
Results
My first Zig program YAYY!
0 0 0 0 0
1 0 0 0 0
2 0 0 0 0
3 0 0 0 0
0 1 2 3
.{ .players = .{ .items = { }, .capacity = 0 }, .active_resource = .Brick }
> hello world
hello world