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

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. }  
posted @ 2015-07-02 14:48  duter  阅读(198)  评论(0)    收藏  举报