Subversion Repositories Kolibri OS

Rev

Rev 6412 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <ctype.h>
  4. #include <string.h>
  5.  
  6. /*
  7. ** itoa(n,s) - Convert n to characters in s
  8. */
  9. char* __itoa(int n,char* s)
  10. {
  11.   int sign;
  12.   char *ptr;
  13.   ptr = s;
  14.  
  15.   if(n == (int)0x80000000)
  16.     return strcpy(s, "-2147483648");  // overflowed -n
  17.  
  18.   if ((sign = n) < 0) n = -n;
  19.   do {
  20.     *ptr++ = n % 10 + '0';
  21.     } while ((n = n / 10) > 0);
  22.   if (sign < 0) *ptr++ = '-';
  23.   *ptr = '\0';
  24.   return strrev(s);
  25. }
  26.  
  27.