From 0b171dce6581f540f231ec877d35304c50f7a37b Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Sat, 9 Nov 2019 17:51:23 +0000 Subject: [PATCH] Start the standard library 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 | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 stdlib.c diff --git a/stdlib.c b/stdlib.c new file mode 100644 index 0000000..9749ee3 --- /dev/null +++ b/stdlib.c @@ -0,0 +1,7 @@ +#include +// Takes a double and writes it to stdout +double putchard(double x) { + int res = putchar((int)x); + fflush(stdout); + return (double)res; +} -- 2.30.2