to_string() 函数
包含头文件 <string>功能:将括号内的 数字 转化为 字符串to_string( idata )#include <string>#include <iostream>int main(){std::string s="the pi is ";std::cout << s << std::endl;s += std:: to_str
·
包含头文件 <string>
功能:将括号内的 数字 转化为 字符串
to_string( idata )
#include <string>
#include <iostream>
int main()
{
std::string s="the pi is ";
std::cout << s << std::endl;
s += std:: to_string(3.141592653589);
std::cout << s << std::endl;
s.clear();
s = std:: to_string(2.7+3.14159);
std:: cout << s << std::endl;
system("pause");
return 0;
}
运行结果:

更多推荐

所有评论(0)