itoa, _itow
Go Up to stdlib.h Index
Header File
stdlib.h
Category
Conversion Routines, Math Routines
Prototype
char *itoa(int value, char *string, int radix);
wchar_t *_itow(int value, wchar_t *string, int radix);
Description
Converts an integer to a string.
itoa converts value to a null-terminated string and stores the result in string. With itoa, value is an integer. _itow is the unicode version of the function. It converts an integer to a wide-character string.
radix specifies the base to be used in converting value; it must be between 2 and 36, inclusive. If value is negative and radix is 10, the first character of string is the minus sign (-).
Note: The space allocated for string must be large enough to hold the returned string, including the terminating null character (\0). itoa can return up to 33 bytes.
Return Value
itoa returns a pointer to string.
Example
#include <stdlib.h> #include <stdio.h> int main(void) { int number = 12345; char string[25]; itoa(number, string, 10); printf("integer = %d string = %s\n", number, string); return 0; }
Portability
POSIX | Win32 | ANSI C | ANSI C++ |
---|---|---|---|
+ |