_ltoa, _ltow Convert a long integer to a string. char *_ltoa( long value, char *string, int radix );wchar_t *_ltow( long value, wchar_t *string, int radix );Routine Required Header Compatibility _ltoa <stdlib.h> Win 95, Win NT _ltow <stdlib.h> Win 95, Win NT Return ValueEach of these functions returns a pointer to string. There is no error return.Parametersvalue Number to be convertedstring String resultradix Base of valueRes The _ltoa function converts the digits of value to a null-terminated character string and stores the result (up to 33 bytes) in string. The radix argument specifies the base of value, which must be in the range 2 – 36. If radix equals 10 and value is negative, the first character of the stored string is the minus sign (–). _ltow is a wide-character version of _ltoa; the second argument and return value of _ltow are wide-character strings. Each of these functions is Microsoft-specific.Example/* ITOA.C: This program converts integers of various * sizes to strings in various radixes. */#include <stdlib.h> #include <stdio.h>void main( void ) { char buffer[20]; long l = -344115L; unsigned long ul = 1234567890UL; _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 ); } OutputString of long int -344115 (radix 16): 0xfffabfcd String of unsigned long 1234567890 (radix 16): 0x499602d2
itoa atoi 还有 sprintf
char *_ltoa( long value, char *string, int radix ); //value:要转换的数值;string:转换后字符串存储起始地址;radix:进制 //返回值:转换后的字符串起始地址;
例如:ltoa(l,temp,10)//其中l代表long型整数,temp是字符串变量,10表示十进制
CString str;
str.Format(_T("%d"), lValue);(2)
LPTSTR psz = new TCHAR[20];
_stprintf(psz, _T("%d"), lValue);
strtemp.Format("",lNum)
或者
__ltoa
Convert a long integer to a string.
char *_ltoa( long value, char *string, int radix );wchar_t *_ltow( long value, wchar_t *string, int radix );Routine Required Header Compatibility
_ltoa <stdlib.h> Win 95, Win NT
_ltow <stdlib.h> Win 95, Win NT
Return ValueEach of these functions returns a pointer to string. There is no error return.Parametersvalue
Number to be convertedstring
String resultradix
Base of valueRes
The _ltoa function converts the digits of value to a null-terminated character string and stores the result (up to 33 bytes) in string. The radix argument specifies the base of value, which must be in the range 2 – 36. If radix equals 10 and value is negative, the first character of the stored string is the minus sign (–). _ltow is a wide-character version of _ltoa; the second argument and return value of _ltow are wide-character strings. Each of these functions is Microsoft-specific.Example/* ITOA.C: This program converts integers of various
* sizes to strings in various radixes.
*/#include <stdlib.h>
#include <stdio.h>void main( void )
{
char buffer[20];
long l = -344115L;
unsigned long ul = 1234567890UL; _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 );
}
OutputString of long int -344115 (radix 16): 0xfffabfcd
String of unsigned long 1234567890 (radix 16): 0x499602d2
atoi
还有
sprintf
//value:要转换的数值;string:转换后字符串存储起始地址;radix:进制
//返回值:转换后的字符串起始地址;