码迷,mamicode.com
首页 > 其他好文 > 详细

double转为string (int\float等类似)

时间:2015-07-02 15:38:59      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:

double转为string (int\float等类似)

Cpp代码  技术分享
  1. Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include <string>   
  2. #inlcude <sstream>  
  3. int main(){  
  4.   double   d=123.456;   
  5.   string   str;   
  6.   stringstream   ss;   
  7.   ss<<d;   
  8.   ss>>str;  
  9. }  

 

string转为double(int\float等类似)

Cpp代码  技术分享
  1. Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include <string>   
  2. #inlcude <sstream>  
  3. int main(){  
  4.   double s;  
  5.   string str="123.56";  
  6.   stringstream ss;  
  7.   ss<<str;//从str输入    
  8.   ss>>s;//输出到double  
  9.   ss.clear();  
  10. }  

double转为string (int\float等类似)

标签:

原文地址:http://www.cnblogs.com/duter/p/4616061.html

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