C++字符串的建立

比如要把三个整型变成连续字符串,应该这样:

#include <iostream>
#include <sstream>  //这个是关键
#include <string>

using namespace std;

int main()

{

int a=1,b=2,c=3;

string s;

stringstream out;

out<<a<<b<<c;

out>>s;   //注意箭头方向

cout<<s<<endl;

return 0;

}

则输出123(字符串);

原文地址:https://www.cnblogs.com/c4isr/p/2407427.html