I/O improvements

This commit is contained in:
Chris Boesch
2026-01-09 22:56:23 +01:00
parent 6972af2178
commit 1e552a1dd6
8 changed files with 26 additions and 28 deletions

View File

@@ -1,5 +1,5 @@
--- exercises/026_hello2.zig 2025-12-30 13:39:29.478620712 +0100
+++ answers/026_hello2.zig 2025-12-30 13:39:18.948412943 +0100
--- exercises/026_hello2.zig 2026-01-09 22:51:45.803358789 +0100
+++ answers/026_hello2.zig 2026-01-09 22:50:46.016166527 +0100
@@ -28,5 +28,5 @@
// to be able to pass it up as a return value of main().
//

View File

@@ -1,11 +1,6 @@
--- exercises/034_quiz4.zig 2025-12-28 14:43:41.087943476 +0100
+++ answers/034_quiz4.zig 2025-12-28 14:42:23.878472164 +0100
@@ -10,11 +10,11 @@
const NumError = error{IllegalNumber};
-pub fn main() void {
+pub fn main() !void {
--- exercises/034_quiz4.zig 2026-01-09 22:45:53.115325559 +0100
+++ answers/034_quiz4.zig 2026-01-09 22:45:15.658578603 +0100
@@ -14,7 +14,7 @@
var stdout_writer = std.Io.File.stdout().writer(io, &.{});
const stdout = &stdout_writer.interface;

View File

@@ -1,6 +1,6 @@
--- exercises/106_files.zig 2025-12-28 20:38:53.005504479 +0100
+++ answers/106_files.zig 2025-12-28 20:37:42.742154100 +0100
@@ -39,7 +39,7 @@
--- exercises/106_files.zig 2026-01-09 22:41:19.373872684 +0100
+++ answers/106_files.zig 2026-01-09 22:41:44.518372910 +0100
@@ -41,7 +41,7 @@
// by doing nothing
//
// we want to catch error.PathAlreadyExists and do nothing
@@ -9,7 +9,7 @@
// if there's any other unexpected error we just propagate it through
else => return e,
};
@@ -59,7 +59,7 @@
@@ -61,7 +61,7 @@
// but here we are not yet done writing to the file
// if only there were a keyword in Zig that
// allowed you to "defer" code execution to the end of the scope...

View File

@@ -1,6 +1,6 @@
--- exercises/107_files2.zig 2025-12-28 21:17:29.658147954 +0100
+++ answers/107_files2.zig 2025-12-28 21:17:10.585787203 +0100
@@ -38,7 +38,7 @@
--- exercises/107_files2.zig 2026-01-09 22:43:15.211177186 +0100
+++ answers/107_files2.zig 2026-01-09 22:42:48.943654602 +0100
@@ -39,7 +39,7 @@
// initialize an array of u8 with all letter 'A'
// we need to pick the size of the array, 64 seems like a good number
// fix the initialization below
@@ -9,7 +9,7 @@
// this should print out : `AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA`
std.debug.print("{s}\n", .{content});
@@ -49,12 +49,12 @@
@@ -50,12 +50,12 @@
// can you go here to find a way to read the content?
// https://ziglang.org/documentation/master/std/#std.Io.Reader
// hint: look for a method that reads into a slice