From de4da84ca3159ad0ebcf13729716be5f4d7bbc2a Mon Sep 17 00:00:00 2001 From: zinc Date: Thu, 15 Oct 2026 09:42:25 +0330 Subject: std: add std.Io (print, println, nl, put_*, put_f, get_c, eof, read, getline) with test, learn example and docs --- examples/learn/35-io.out | 3 +++ examples/learn/35-io.zc | 7 +++++++ examples/std_tour.zc | 3 +++ 3 files changed, 13 insertions(+) create mode 100644 examples/learn/35-io.out create mode 100644 examples/learn/35-io.zc (limited to 'examples') diff --git a/examples/learn/35-io.out b/examples/learn/35-io.out new file mode 100644 index 0000000..9aa7f64 --- /dev/null +++ b/examples/learn/35-io.out @@ -0,0 +1,3 @@ +total: 42 +ratio: 0.250000 +done diff --git a/examples/learn/35-io.zc b/examples/learn/35-io.zc new file mode 100644 index 0000000..e370daa --- /dev/null +++ b/examples/learn/35-io.zc @@ -0,0 +1,7 @@ +namespace; +include std; +fn main() { + std.Io.print("total: "); std.Io.put_n(6 * 7); std.Io.nl(); + std.Io.print("ratio: "); std.Io.put_f(1.0 / 4.0); std.Io.nl(); + std.Io.println("done"); +} diff --git a/examples/std_tour.zc b/examples/std_tour.zc index df4d02b..1ef33f3 100644 --- a/examples/std_tour.zc +++ b/examples/std_tour.zc @@ -9,6 +9,9 @@ int dbl(int x) { return x * 2; } int add(int a, int b) { return a + b; } fn main() { + // io: the terminal + std.Io.print("io "); std.Io.put_n(7); std.Io.put_c(' '); std.Io.put_f(0.5); std.Io.nl(); // io 7 0.500000 + // text: char* strings, one character per word let buf[32]; std.Text.itoa(0 - 42, buf); rt.put_s(buf); rt.put_c(10); // -42 -- cgit v1.2.3