使用stringstream
#include <string>
#include <sstream>
using namespace std;
int main()
{
stringstream strStream;
int code = 100;
float value = 10.8;
strStream << "code:" << code << ",value:" << value;
string content = strStream.str();
return 0;
}