diff options
Diffstat (limited to 'libc/stdlib.c')
| -rw-r--r-- | libc/stdlib.c | 15 |
1 files changed, 15 insertions, 0 deletions
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 <stdlib.h> + +/* adapted from <http://www.strudel.org.uk/itoa/> */ +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]; +} |