utoa()

Convert an unsigned integer into a string, using a given base

Synopsis:

#include <stdlib.h>

char* utoa( unsigned int value,
            char* buffer,
            int radix );

Arguments:

value
The value to convert into a string.
buffer
A buffer in which the function stores the string. The size of the buffer must be at least:
8 × sizeof( int ) + 1
  

bytes when converting values in base 2 (binary).

radix
The base to use when converting the number.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The utoa() function converts the unsigned binary integer value into the equivalent string in base radix notation, storing the result in the character array pointed to by buffer. A null character is appended to the result.

Returns:

A pointer to the result.

Examples:

#include <stdio.h>
#include <stdlib.h>

int main( void )
  {
    int base;
    char buffer[18];

    for( base = 2; base <= 16; base = base + 2 )
      printf( "%2d %s\n", base,
          utoa( (unsigned) 12765, buffer, base ) );
    return EXIT_SUCCESS;
  }

produces the output:

 2 11000111011101
 4 3013131
 6 135033
 8 30735
10 12765
12 7479
14 491b
16 31dd

Classification:

QNX 4

Safety:  
Cancellation point No
Interrupt handler Yes
Signal handler Yes
Thread Yes