可以使用ostringstream进行拼接
举个例子
#include<iostream>
#include<ctime>
#include<sstream>
using namespace std;
int main()
{
ostringstream os;
os<<"我已经玩王者荣耀"<<4<<"年了";
//输出
cout<<os.str() <<endl;
}
运行结果是
拼接完全不受限制
可以使用ostringstream进行拼接
举个例子
#include<iostream>
#include<ctime>
#include<sstream>
using namespace std;
int main()
{
ostringstream os;
os<<"我已经玩王者荣耀"<<4<<"年了";
//输出
cout<<os.str() <<endl;
}
运行结果是
拼接完全不受限制