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;
}