函数原形
char *itoa(int value, char *string, int radix)
将整形数value转换为其等价的字符串
头文件stdlib.h
Parameters(参数说明)
value
Number to be converted(将要被转换的值)
string
String result(转换的结果)
radix
Base of value; must be in the range 2 – 36
(转换的基数,取值范围2-36。例如radix=10表示10进制,radix=8表示8进制。)
返回值:与string参数相同,便于函数的嵌套调用
例子:(来自MSDN,有删改)
#i nclude <stdlib.h>
#i nclude <stdio.h>
void main( void )
{
char buffer[20];
int
i = 3445;
itoa( i, buffer, 10 );
printf( "String of integer %d (radix 10): %s\n", i, buffer );
itoa( i, buffer, 16 );
printf( "String of integer %d (radix 16): 0x%s\n", i, buffer );
itoa( i, buffer, 2
);
printf( "String of integer %d (radix 2): %s\n", i, buffer );
system("pause");
}