上古卷轴5各大主城任务:如何将一个64位整数转换成数组?

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/28 12:23:36
如何将一个64位整数转换成数组?

就是把那个数的每一位都防入数组中`

??什么叫把数转换成数组?说详细一点。

char *myi64toa( __int64 value, char *str, int radix )
{
static char szMap[] = {
'0', '1', '2', '3', '4', '5',
'6', '7', '8', '9', 'a', 'b',
'c', 'd', 'e', 'f', 'g', 'h',
'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z'
};
if ( radix >= 2 && radix <= 36 && str )
{
char *pStr, nTemp;
int nCount = 0, nIndex = 0;
if ( value < 0 )
{
pStr = str + 1;
value = -value;
}
do
{
pStr[ nCount++ ] = szMap[ value % radix ];
value /= radix;
} while( value > 0 );
nIndex = nCount-- / 2;
while( nIndex-- > 0 )
{
nTemp = pStr[ nIndex ];
pStr[ nIndex ] = pStr[ nCount - nIndex ];
pStr[ nCount - nIndex ] = nTemp;
}
pStr[ nCount + 1 ] = '\0';
if ( pStr != str )
{
str[0] = '-';
}
}
return str;
}