diff options
Diffstat (limited to 'src/base/string/raw/itoa.c')
-rw-r--r-- | src/base/string/raw/itoa.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/base/string/raw/itoa.c b/src/base/string/raw/itoa.c new file mode 100644 index 0000000..38a6661 --- /dev/null +++ b/src/base/string/raw/itoa.c @@ -0,0 +1,21 @@ +static char * +kernel(char *s, int x) +{ + if(x/10) + s = kernel(s, x/10); + *s++ = x%10 + '0'; + return s; +} + +char * +strĀ·itoa(char *s, int x) +{ + if(x<0){ + *s++ = '-'; + x=-x; + } + s = kernel(s, x); + *s = '0'; + + return s; +} |