首页 > 其他 > 详细

stringstream 类型转换

时间:2018-04-28 18:40:36      阅读:139      评论:0      收藏:0      [点我收藏+]

stringstream可以吞下不同的类型,然后吐出不同的类型。

这样可以实现int,string,double等类型的转换

 

 1 #include<sstream>
 2 
 3 using namespace std;
 4 
 5 int main()
 6 {
 7         int x;
 8         stringstream temp;
 9     temp << x;//吞入被转换的类型
10         string s1 = temp .str();//吐出需要的类型
11 }
12     

 

stringstream 类型转换

原文:https://www.cnblogs.com/xiaoxue126/p/8969021.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!