exc. 34 migrated

This commit is contained in:
Chris Boesch 2025-12-28 14:46:23 +01:00
parent 8e30debc6a
commit 8f9daa12b2
No known key found for this signature in database
GPG Key ID: 8712DF4D3E364668
2 changed files with 10 additions and 7 deletions

View File

@ -6,15 +6,17 @@
// my_num=42
//
const std = @import("std");
const io = std.Options.debug_io;
const NumError = error{IllegalNumber};
pub fn main() void {
var stdout = std.fs.File.stdout().writer(&.{});
var stdout_writer = std.Io.File.stdout().writer(io, &.{});
const stdout = &stdout_writer.interface;
const my_num: u32 = getNumber();
try stdout.interface.print("my_num={}\n", .{my_num});
try stdout.print("my_num={}\n", .{my_num});
}
// This function is obviously weird and non-functional. But you will not be changing it for this quiz.

View File

@ -1,15 +1,16 @@
--- exercises/034_quiz4.zig 2025-07-22 09:55:51.337832401 +0200
+++ answers/034_quiz4.zig 2025-07-22 10:05:08.320323184 +0200
@@ -9,10 +9,10 @@
--- 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 {
var stdout = std.fs.File.stdout().writer(&.{});
var stdout_writer = std.Io.File.stdout().writer(io, &.{});
const stdout = &stdout_writer.interface;
- const my_num: u32 = getNumber();
+ const my_num: u32 = try getNumber();
try stdout.interface.print("my_num={}\n", .{my_num});
try stdout.print("my_num={}\n", .{my_num});
}