#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main()
{
//方法一:使用标准库的to_string函数
int num = 123;
cout << to_string(num) << endl;
//方法二:使用ostringstream
num = 456;
ostringstream os;
os << num;
string str = os.str();
cout << str << endl;
//方法三:使用sprintf_s函数
num = 789;
char buff[100];
sprintf_s(buff, "%d", num);
cout << buff << endl;
return 0;
}
01-20
01-10
5万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-27
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交