summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-23 12:22:57 +0000
committerZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-23 12:22:57 +0000
commitf73df8d5de30a7f3f320fccf5f57c13094940a6a (patch)
tree877fda85fa3c4a906d6943ac7b7836886bc4140a /docs
parent98623f2fdd63232edf0ebab1b9680cf4e33e6f10 (diff)
Variadic functions + more docs
Diffstat (limited to 'docs')
-rw-r--r--docs/std/README.md1
-rw-r--r--docs/std/io.md44
2 files changed, 45 insertions, 0 deletions
diff --git a/docs/std/README.md b/docs/std/README.md
index f15b67a..6125a4e 100644
--- a/docs/std/README.md
+++ b/docs/std/README.md
@@ -2,6 +2,7 @@
- [Env (Environment)](./env.md) - Process environment variables.
- [File System (FS)](./fs.md) - File I/O and directory operations.
+- [IO](./io.md) - Standard Input/Output.
- [Map](./map.md) - Hash map implementation.
- [Option](./option.md) - Optional values (Some/None).
- [Path](./path.md) - File path manipulation.
diff --git a/docs/std/io.md b/docs/std/io.md
new file mode 100644
index 0000000..825728d
--- /dev/null
+++ b/docs/std/io.md
@@ -0,0 +1,44 @@
+# Standard Library: IO (`std/io.zc`)
+
+The `std/io` module provides standard input/output functionality, including printing to stdout and reading from stdin.
+
+## Usage
+
+```zc
+import "std/io.zc"
+
+fn main() {
+ // Printing
+ io.println("Hello %s", "World");
+
+ // Formatting strings
+ autofree var s = io.format_new("Value: %d", 42);
+
+ // Reading input
+ io.print("Enter name: ");
+ autofree var name = io.readln();
+}
+```
+
+## Functions
+
+### Output
+
+| Function | Signature | Description |
+| :--- | :--- | :--- |
+| **print** | `print(fmt: char*, ...) -> int` | Prints formatted output to stdout. |
+| **println** | `println(fmt: char*, ...) -> int` | Prints formatted output to stdout with a newline. |
+
+### Formatting
+
+| Function | Signature | Description |
+| :--- | :--- | :--- |
+| **format** | `format(fmt: char*, ...) -> char*` | Formats string into a static buffer (returns pointer). **Not thread-safe**. |
+| **format_into** | `format_into(buf: char*, size: usize, fmt: char*, ...) -> int` | Formats string into a user-provided buffer. |
+| **format_new** | `format_new(fmt: char*, ...) -> char*` | Formats string into a newly allocated buffer (caller must free). |
+
+### Input
+
+| Function | Signature | Description |
+| :--- | :--- | :--- |
+| **readln** | `readln() -> char*` | Reads a line from stdin. Returns heap-allocated string (caller must free) or `NULL` on EOF/error. |