C++中的stringstream是专门用来处理字符串流的,可以按顺序将string或int都拼接起来,而不用把int转换为string格式,使用方法如下:
#include#include #include stringstream strstream;std::string s;std::string s1 = "hello";int d = 13;strstream.str(""); strstream.clear();strstream << s1 << "world" << d << "!"; strstream >> s;