/****************************************************************************
 *
 *    NAME: UlToStr
 * PURPOSE: Convert unsigned long to decimal string.
 *
 * SYNOPSIS:   void UlToStr(char *s, unsigned long bin, unsigned char n);
 *
 * DESCRIPTION:
 *
 *     The function stores a NUL-terminated string, in "n" + 1 (plus 1 for
 *     the NUL string terminator) successive elements of the array whose
 *     first element has the address "s", by converting "bin" to "n" decimal
 *     characters.
 *
 ****************************************************************************/

void UlToStr(char *s, unsigned long bin, unsigned char n)
{
    s += n;
    *s = ' ';

    while (n--)
    {
        *--s = (bin % 10) + '0';
        bin /= 10;
    }
}