#include <iostream>#include <string>usingnamespacestd;
int main()
{
int n = 65535;
char t[256];
string s;
sprintf(t, "%d", n);
s = t;
cout << s << endl;
return0;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
第二种方式
#include <iostream>#include <string>#include <strstream>usingnamespacestd;
int main()
{
int n = 65535;
strstream ss;
string s;
ss << n;
ss >> s;
cout << s << endl;
return0;
}