minix/lib/libminlib/itoa.c
Ben Gras 6a73e85ad1 retire _PROTOTYPE
. only good for obsolete K&R support
	. also remove a stray ansi.h and the proto cmd
2012-03-25 16:17:10 +02:00

37 lines
481 B
C

#include <lib.h>
/* Integer to ASCII for signed decimal integers. */
PRIVATE int next;
PRIVATE char qbuf[8];
char *itoa(int n);
char *itoa(n)
int n;
{
register int r, k;
int flag = 0;
next = 0;
if (n < 0) {
qbuf[next++] = '-';
n = -n;
}
if (n == 0) {
qbuf[next++] = '0';
} else {
k = 10000;
while (k > 0) {
r = n / k;
if (flag || r > 0) {
qbuf[next++] = '0' + r;
flag = 1;
}
n -= r * k;
k = k / 10;
}
}
qbuf[next] = 0;
return(qbuf);
}