Skip to content

Instantly share code, notes, and snippets.

@siberiy4
Created July 21, 2022 09:43
Show Gist options
  • Save siberiy4/b8f2f1ab351263dde5006403801719ed to your computer and use it in GitHub Desktop.
Save siberiy4/b8f2f1ab351263dde5006403801719ed to your computer and use it in GitHub Desktop.
const std = @import("std");
const print = std.debug.print;
const stdout = std.io.getStdOut().writer();
const stdin = std.io.getStdIn().reader();
pub fn input() ![]u8 {
var buf = std.ArrayList(u8).init(std.testing.allocator);
defer buf.deinit();
while (true) {
const byte = stdin.readByte() catch |err| switch (err) {
error.EndOfStream => {
break;
},
else => {
return undefined;
// return buf;
},
};
if(byte=='\n'){
break;
}
try buf.append(byte);
}
return buf.toOwnedSlice();
}
pub fn main() !void {
var buf =input();
try print(":{}\n",.{@typeName(@TypeOf(buf))});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment