From e63e7123cdaac69f5b7216319681eea97e7aeb64 Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Thu, 5 Feb 2015 20:59:33 -0500 Subject: add stdlib --- libc/stdlib.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 libc/stdlib.c (limited to 'libc/stdlib.c') diff --git a/libc/stdlib.c b/libc/stdlib.c new file mode 100644 index 0000000..356fc33 --- /dev/null +++ b/libc/stdlib.c @@ -0,0 +1,15 @@ +#include + +/* adapted from */ +char* itoa(int val, int base) +{ + static char buf[32] = {0}; + + int i = 30; + + for(; val && i ; --i, val /= base) + + buf[i] = "0123456789abcdef"[val % base]; + + return &buf[i+1]; +} -- cgit v1.1