Created
July 21, 2022 09:43
-
-
Save siberiy4/b8f2f1ab351263dde5006403801719ed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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