Rev 647 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 647 | Rev 6412 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #include "stdio.h" |
1 | #include |
2 | #include "stdlib.h" |
2 | #include |
3 | #include "ctype.h" |
3 | #include |
- | 4 | #include |
|
Line 4... | Line 5... | ||
4 | 5 | ||
5 | /* |
6 | /* |
6 | ** itoab(n,s,b) - Convert "unsigned" n to characters in s using base b. |
7 | ** itoab(n,s,b) - Convert "unsigned" n to characters in s using base b. |
7 | ** NOTE: This is a non-standard function. |
8 | ** NOTE: This is a non-standard function. |
8 | */ |
9 | */ |
9 | void itoab(int n,char* s,int b) |
10 | char* itoab(int n,char* s,int b) |
10 | { |
11 | { |
11 | char *ptr; |
12 | char *ptr; |
12 | int lowbit; |
13 | int lowbit; |
13 | ptr = s; |
14 | ptr = s; |
Line 18... | Line 19... | ||
18 | *ptr = ((n % b) << 1) + lowbit; |
19 | *ptr = ((n % b) << 1) + lowbit; |
19 | if(*ptr < 10) *ptr += '0'; else *ptr += 55; |
20 | if(*ptr < 10) *ptr += '0'; else *ptr += 55; |
20 | ++ptr; |
21 | ++ptr; |
21 | } while(n /= b); |
22 | } while(n /= b); |
22 | *ptr = 0; |
23 | *ptr = 0; |
23 | reverse (s); |
24 | return strrev(s); |
24 | }>><> |
25 | }>><> |