C++ 整数转换为字符串:to_string() 函数详解
可以使用标准库函数 to_string() 将整型数据转换成字符串型数据。
示例代码:
#include <iostream>
#include <string>
using namespace std;
int main()
{
int num = 123;
string str = to_string(num);
cout << '转换后的字符串为:' << str << endl;
return 0;
}
输出结果:
转换后的字符串为:123
原文地址: https://www.cveoy.top/t/topic/l37n 著作权归作者所有。请勿转载和采集!