C++ string和int互相转换
int转string
int aa = 30; stringstream ss; ss<<aa; string s1 = ss.str(); cout<<s1<<endl; // 30 string s2; ss>>s2; cout<<s2<<endl; // 30
string转int
string s = "17"; stringstream ss; ss<<s; int i; ss>>i; cout<<i<<endl; // 17
int aa = 30; stringstream ss; ss<<aa; string s1 = ss.str(); cout<<s1<<endl; // 30 string s2; ss>>s2; cout<<s2<<endl; // 30
string s = "17"; stringstream ss; ss<<s; int i; ss>>i; cout<<i<<endl; // 17