自己写的一个算法:将一个int型数转换为string
char *itoa(int num, char *str)
{
assert(NULL != str);
int i=1, j=0;
if (num < 0)
{
str[j++]='-';
num = (-1)*num;
}
if (0 == num)
{
str[j++] = '0';
str[j] = '\0';
return str;
}
while (! (num/i < 10))
{
i = i*10;
}
while (num > 0)
{
str[j++] = num/i + 0x30;
num = num % i;
i = i/10;
}
str[j]='\0';
return(str);
}