]> diplodocus.org Git - nmh/blob - docs/historical/mh-jun-1982/Extras/libh/prndec.c
Replaced use of snprintf() with memcpy()/memmove().
[nmh] / docs / historical / mh-jun-1982 / Extras / libh / prndec.c
1 #ifdef COMMENT
2 Proprietary Rand Corporation, 1981.
3 Further distribution of this software
4 subject to the terms of the Rand
5 license agreement.
6 #endif
7
8 prndec(ch, d)
9 {
10 char buf[8];
11 register char *cp;
12 register int i, j;
13
14 i = d;
15 cp = &buf[8];
16 *--cp = 0;
17 j = 0;
18 if(i < 0) {
19 i =- i;
20 j =+ 10;
21 }
22 do {
23 *--cp = (i % 10) + '0';
24 i =/ 10;
25 j++;
26 } while(i);
27 if(j > 10) {
28 j =- 9;
29 *--cp = '-';
30 }
31 write(ch, cp, j);
32 return(j);
33 }