Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 32 lines (23 sloc) 0.425 kB
1cef37b @spott moved files around, edited makefile
authored
1 #include "spottlib.h";
2
3 void reverse(char *s) {
4 int c, i ,j;
5
6 for (i = 0, j = strlen(s)-1; i < j; i++, j--) {
7 c = s[i];
8 s[i] = s[j];
9 s[j] = c;
10 }
11 }
12
13 //from K&R pg 64:
14 void itoa(int n, char *s) {
15 int i, sign;
16
17 if ((sign = n) < 0)
18 n = -n;
19 i = 0;
20
21 do { /*generate digits in reverse order */
22 s[i++] = n % 10 + '0';
23 } while ((n /= 10) > 0);
24
25 if (sign < 0)
26 s[i++] = '-';
27 s[i] = '\0';
28 reverse(s);
29 }
30
31
Something went wrong with that request. Please try again.