int string相互转换

string stream1(ll i)
{
    stringstream stream;
    stream<<i;
    return stream.str();
}//int数字转字符串
ll stream2(string str)
{
    ll x = 0;
    stringstream ss;
    ss<<str;
    ss>>x;
    return x;
}
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    string t = "123456789";
    stringstream ss(t);
    int A;
    ss>>A;
    cout<<A<<endl;

    int t2 = 123456789;
    stringstream sss;
    sss<<t2;
    cout<<sss.str()<<endl;
    return 0;
}
原文地址:https://www.cnblogs.com/tonyyy/p/10590176.html