C++ int 类型转 string 类型
string int2str(int n){
int m = n;
char s;
char ss;
int i = 0, j = 0;
if (n < 0)
{
m = 0 - m;
j = 1;
ss = '-';
}
while (m > 0)
{
s = m % 10 + '0';
m /= 10;
}
s = '\0';
i = i - 1;
while (i >= 0)
{
ss = s;
}
ss = '\0';
string res = ss;
return res;
}
页:
[1]