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

number to string

时间:2016-04-19 18:48:13      阅读:119      评论:0      收藏:0      [点我收藏+]

标签:

C++进行int to string和string to int

下面方法一存在内存泄露

#include<strstream>
void main()
{
  std::strstream ss;
  int n = 2;
  ss<<n;
  std::string str = ss.str();

}
这个方法可以,
好用
#include<sstream>
void main()
{
  std::stringstream ss;
  int n = 2;
  ss<<n;
  std::string str = ss.str();

}

 string to number

#include<sstream>
void main()

{
  std::string str = "12"
  std::stringstream ss(str);
  int n;
  ss>>n;
}
 
 

 

number to string

标签:

原文地址:http://www.cnblogs.com/geospatial/p/5409104.html

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