C++中int转string与string转int

时间:2021-06-07 01:09:31
#include "stdafx.h"
#include "string"
#include "iostream"
#include "vector"
#include "sstream"
using namespace std; int _tmain(int argc, _TCHAR* argv[])
{
//string 转 int
stringstream ss;
string str;
int i;
ss<<"";
ss>>i;
i=i+;
cout<<i<<endl;//输出结果200 //int 转 string
stringstream ssm;
ssm<<;
str=ssm.str();
str=str+"";
cout<<str;//输出结果58
getchar(); return ;
}