码迷,mamicode.com
首页 > 编程语言 > 详细

C++中string类型对象和double型变量之间的互相转换

时间:2014-06-09 22:15:55      阅读:220      评论:0      收藏:0      [点我收藏+]

标签:c   style   a   color   string   os   

//convert string type value to double type value
string s = "23";
double d;
istringstream is(s);
is>>d;
cout<<d<<endl;   //输出23

 

//convert double type value to string type value
double d=45;
string s;
ostringstream os;
os<<d;
s = os.str();
cout<<s<<endl;  //输出45

C++中string类型对象和double型变量之间的互相转换,布布扣,bubuko.com

C++中string类型对象和double型变量之间的互相转换

标签:c   style   a   color   string   os   

原文地址:http://www.cnblogs.com/Marrybe/p/3775296.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!