_itoa

C語言函式,作用為將整形轉換為字元串 int--->char*

形轉換為字元串 int--->char*
char*_itoa(intvalue,char*string,intradix);

參數說明:

value-----要轉換的整形值
string-----轉換後的字元串
radix------表示基數(2, 8, 10, 16)等進制基數
本函式與char * itoa(int, char *, int);相同
還有其他類似的轉換函式
char *_i64toa(__int64value,char*string,intradix);
char*_ui64toa(unsigned_int64value,char*string,intradix);
wchar_t*_itow(intvalue,wchar_t*string,intradix);
wchar_t*_i64tow(__int64value,wchar_t*string,intradix);
wchar_t*_ui64tow(unsigned __int64value,wchar_t*string,intradix);
後三個為轉換寬字元
eg:
#include <stdlib.h>
#include <stdio.h>
void main( void )
{
char buffer&#91;20&#93;;
int i = 3445;
long l = -344115L;
unsigned long ul = 1234567890UL;
_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 );
_ltoa( l, buffer, 16 );
printf( "String of long int %ld (radix 16): 0x%s\n", l,
buffer );
_ultoa( ul, buffer, 16 );
printf( "String of unsigned long %lu (radix 16): 0x%s\n", ul,
buffer );
}
output:
String of integer 3445 (radix 10): 3445
String of integer 3445 (radix 16): 0xd75
String of integer 3445 (radix 2): 110101110101
String of long int -344115 (radix 16): 0xfffabfcd
String of unsigned long 1234567890 (radix 16): 0x499602d2
說明:例題來自MSDN 2002

相關詞條

熱門詞條

聯絡我們