函式原形
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");
}
函式原形
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");
}