Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Turbo C - <b>ultoa() convert unsigned long to string</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
ultoa()                  Convert Unsigned Long to String

 #include   <stdlib.h>                   Required for declarations only

 char           ultoa(value,string,radix);
 unsigned long  value;                   Number to be converted
 char           *string;                 String result
 int            radix;                   Base of 'value'

    ultoa() converts 'value' to a null-terminated string stored at
    'string'.  'radix' specifies the base of 'value', which must be in
    the range of 2-36.  No overflow checking is performed.

    Returns:    A pointer to 'string'.  There is no error return.

      Notes:    The space allocated for '*string' must be large enough to
                hold the returned string, which can be up to 33 bytes.

  -------------------------------- Example ---------------------------------

    The following statements convert an unsigned long integer value into
    a string, using base 16, and print the result.

           #include <stdlib.h>

           unsigned long val = 615584;
           int radix = 16;
           char buffer[40];
           char *p;

           main()
           {
               p = ultoa(val,buffer,radix);
               printf("the hexadecimal representation of %ld is %s\n",val,p);
           }

See Also: itoa() ltoa()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson