Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
8622 | Boppan | 1 | #include |
2 | /* |
||
3 | char* itoa(int n, char* s) |
||
4 | { |
||
5 | int sign; |
||
6 | char *ptr; |
||
7 | ptr = s; |
||
8 | |||
9 | if(n == (int)0x80000000) |
||
10 | return strcpy(s, "-2147483648"); // overflowed -n |
||
11 | |||
12 | if ((sign = n) < 0) n = -n; |
||
13 | do { |
||
14 | *ptr++ = n % 10 + '0'; |
||
15 | } while ((n = n / 10) > 0); |
||
16 | if (sign < 0) *ptr++ = '-'; |
||
17 | *ptr = '\0'; |
||
18 | return strrev(s); |
||
19 | } |
||
20 | */>> |