itoa
Converts an integer to a string
#include <stdlib.h> char *itoa ( int value, char *buffer, int radix);
itoa returns the pointer to the result.
The itoa function converts the 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.
The size of buffer must be at least (8 * sizeof (int) + 1) bytes when converting values in base 2. That makes the size 17 bytes on 16-bit machines and 33 bytes on 32-bit machines. If the value of radix is 10 and value is negative, a minus sign (- ) is prepended to the result.
#include <stdio.h> #include <stdlib.h> int main() { char buffer[20]; int base; for (base=8; base<=16; base=base+2) printf ("%2d %s\n", base, itoa (12765, buffer, base) ); }
produces the following:
8 30735 10 12765 12 7479 14 491b 16 31dd