Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/i/itoa.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/i/itoa.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/i/itoa.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/i/itoa.html on line 8

itoa()

Convert an integer into a string, using a given base

Synopsis:

#include <stdlib.h>

char* itoa( 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.

If the value of radix is 10, and value is negative, then a minus sign is prepended to the result.

Library:

libc

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

Description:

The itoa() function converts the integer value into the equivalent string in base radix notation, storing the result in the specified buffer. The function terminates the string with a NUL character.

Returns:

A pointer to the resulting string.

Examples:

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

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

    for( base = 2; base <= 16; base += 2 ) {
        printf( "%2d %s\n", base,
            itoa( 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

See also:

atoi(), atol(), ltoa(), sscanf(), strtol(), strtoul(), ultoa(), utoa()


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/i/itoa.html on line 167

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/i/itoa.html on line 167