Start the standard library
authorLuke Lau <luke_lau@icloud.com>
Sat, 9 Nov 2019 17:51:23 +0000 (17:51 +0000)
committerLuke Lau <luke_lau@icloud.com>
Sat, 9 Nov 2019 17:53:17 +0000 (17:53 +0000)
Our standard library so far is just going to contain a single function
that acts as a version of putchar(3), except it operates on doubles.
We'll also flush stdout so that we can immediately see what we've
printed when we're inside the repl.

stdlib.c [new file with mode: 0644]

diff --git a/stdlib.c b/stdlib.c
new file mode 100644 (file)
index 0000000..9749ee3
--- /dev/null
+++ b/stdlib.c
@@ -0,0 +1,7 @@
+#include <stdio.h>
+// Takes a double and writes it to stdout
+double putchard(double x) {
+       int res = putchar((int)x);
+       fflush(stdout);
+       return (double)res;
+}