first commit

This commit is contained in:
Kitteh 2021-06-01 10:38:42 +01:00
commit 9b51842ca5
4 changed files with 29 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
material

19
src/main.zig Normal file
View file

@ -0,0 +1,19 @@
const std = @import("std");
const read = @import("./qtshit/read.zig");
const write = @import("./qtshit/write.zig");
pub fn main() !void {
const stdout = std.io.getStdOut().writer();
try stdout.print("Hello, {s}!\n", .{"world"});
var byteList = std.ArrayList(u8).init(std.heap.page_allocator);
defer byteList.deinit();
try write.add_int(byteList.writer(), 4242);
var reader = std.io.fixedBufferStream(byteList.items).reader();
try stdout.print("Number: {} \n", .{try read.get_int(reader)});
}

3
src/qtshit/read.zig Normal file
View file

@ -0,0 +1,3 @@
pub fn get_int(reader: anytype) !u16 {
return try reader.readIntBig(u16);
}

6
src/qtshit/write.zig Normal file
View file

@ -0,0 +1,6 @@
const std = @import("std");
pub fn add_int(writer: anytype, number: u16) !void {
try writer.writeIntBig(u32, 10);
}