/*-----------------------------------------------------------------------75
** File: itoa.0r1.c	By: s_dubrovich@yahoo.com
** ?(c): COPYLEFT
** Last: 12-May-11 06:37:41 PM
** Prev: 12-May-11 06:37:41 PM
** Init: 12-May-11 06:37:41 PM
** Vers: 0r1
** Note: This is a misc function, support to small-c.
**  small-c doesn't handle: char *list[numb] - declare as int's.
**-----------------------------------------------------------------------75
*/

/*-----------------------------------------------------------------------75
** itoa(i) int i;   return -> char &str[0]
** -convert int to ascii decimal string. return &str[0] or -1 on error.
*/

char nstr[6];	/** static array for number to decimal str conversion **/

itoa(i) int i;
{
	int number, ndx, divisor;
	char digit;

	ndx = 0;
	divisor = 10000;	/** printable range for int is 0..65535 **/
	number = i;

	while (divisor >= 1)
		{
		digit = number / divisor + '0';

		/** fill number str array **/
		/** putchar(c); ** pass back ptr to decimal str for user **/

		nstr[ndx++] = digit;
		
		number = number % divisor;
		divisor = divisor / 10;
		}
	nstr[ndx] = 0;
	return (&nstr[0]);
}				/** EO itoa **/

/** EO ITOA.C **/