_ultoa - Convert Unsigned Long Integer to String

Format

#include <stdlib.h>
char *_ultoa(unsigned long value, char *string, int radix);

Note:
The _ultoa function is supported only for C++, not for C.

Language Level: Extension

Threadsafe: Yes.

Description

_ultoa converts the digits of the given unsigned long value to a character string that ends with a null character and stores the result in string. The radix argument specifies the base of value; it must be in the range 2 to 36.

Note:
The space allocated for string must be large enough to hold the returned string. The function can return up to 33 bytes including the null character (\0).

Return Value

_ultoa returns a pointer to string. There is no error return value.

When the string argument is NULL or the radix is outside the range 2 to 36, errno will be set to EINVAL.

Example that uses _ultoa()

This example converts the integer value 255 to a decimal, binary, and hexadecimal representation.

#include <stdio.h>
#include <stdlib.h>
int main(void)
{
   char buffer[35];
   char *p;
   p = _ultoa(255UL, buffer, 10);
   printf("The result of _ultoa(255) with radix of 10 is %s\n", p);
   p = _ultoa(255UL, buffer, 2);
   printf("The result of _ultoa(255) with radix of 2\n    is %s\n", p);
   p = _ultoa(255UL, buffer, 16);
   printf("The result of _ultoa(255) with radix of 16 is %s\n", p);
   return 0;
}

The output should be:

      The result of _ultoa(255) with radix of 10 is 255
      The result of _ultoa(255) with radix of 2
          is 11111111
      The result of _ultoa(255) with radix of 16 is ff

Related Information



[ Top of Page | Previous Page | Next Page | Contents | Index ]