分类: C/C++
2008-04-08 08:41:09
itoa函数 | |
char *itoa(int value, char *string, int radix) 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 #i nclude 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"); } |
|