aboutsummaryrefslogtreecommitdiff
path: root/lib/string/itoa.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/string/itoa.c')
-rw-r--r--lib/string/itoa.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/string/itoa.c b/lib/string/itoa.c
new file mode 100644
index 0000000..5eefb37
--- /dev/null
+++ b/lib/string/itoa.c
@@ -0,0 +1,13 @@
+#include "string.h"
+
+char *
+itoa(char *p, unsigned x)
+{
+ p += 3 * sizeof(int);
+ *--p = 0;
+ do {
+ *--p = '0' + x % 10;
+ x /= 10;
+ } while (x);
+ return p;
+}