mirror of
https://codeberg.org/ziglings/exercises.git
synced 2026-07-28 18:25:16 +00:00
Compare commits
6 Commits
89fe65c158
...
a5ed7b636b
| Author | SHA1 | Date | |
|---|---|---|---|
| a5ed7b636b | |||
| ba99eea43b | |||
| 708436c63d | |||
| e65b359055 | |||
| 719f7f0740 | |||
| 9a1ff49206 |
@@ -30,3 +30,11 @@ pub fn main(init: std.process.Init) !void {
|
||||
// We just learned of a single statement which can accomplish this.
|
||||
stdout.print("Hello world!\n", .{});
|
||||
}
|
||||
|
||||
// Now you must be thinking "Why would I need to do this instead of good
|
||||
// old 'std.debug.print()'?", but here's what you need to understand:
|
||||
// 'std.debug.print()' prints its output to stderr, while the stdout_writer
|
||||
// approach prints to stdout.
|
||||
// A common practice is to pipe output of a command to other commands,
|
||||
// and in order for the piping to work, those commands expect thier input
|
||||
// to come from stdout, not stderr.
|
||||
|
||||
@@ -104,6 +104,11 @@ fn thread_pi(pi: *f64, begin: u64, count: u64) !void {
|
||||
// is created. Otherwise the debug functions slow down the speed
|
||||
// to such an extent that seconds become minutes during execution.
|
||||
//
|
||||
// You can use the following command to build and run this
|
||||
// exercise with the "ReleaseFast" flag:
|
||||
//
|
||||
// zig run exercises/108_threading2.zig -O ReleaseFast
|
||||
//
|
||||
// And you should remove the formatting restriction in "print",
|
||||
// otherwise you will not be able to see the additional digits.
|
||||
//
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
--- 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 @@
|
||||
--- exercises/026_hello2.zig 2026-07-01 16:27:18.674459266 +0200
|
||||
+++ answers/026_hello2.zig 2026-07-01 16:27:08.579220702 +0200
|
||||
@@ -28,7 +28,7 @@
|
||||
// to be able to pass it up as a return value of main().
|
||||
//
|
||||
// We just learned of a single statement which can accomplish this.
|
||||
- stdout.print("Hello world!\n", .{});
|
||||
+ try stdout.print("Hello world!\n", .{});
|
||||
}
|
||||
|
||||
// Now you must be thinking "Why would I need to do this instead of good
|
||||
|
||||
Reference in New Issue
Block a user