std::cerr << segment_term.str() << endl;
2020-01-19 21:11 xplorerthik 阅读(210) 评论(0) 编辑 收藏 举报<sstream>库定义了三种类:istringstream、ostringstream和stringstream,分别用来进行流的输入、输出和输入输出操作。
1.stringstream::str(); returns a string object with a copy of the current contents of the stream.
2.stringstream::str (const string& s); sets s as the contents of the stream, discarding any previous contents.
3.stringstream清空,stringstream s; s.str("");
stringstream segment_term;
segment_term <<"";
for (int j = 0; j< jbterms.size(); ++j)
{
if(j < jbterms.size()-1)
{
//cout<< jbterms[j].word <<endl;
segment_term << jbterms[j].word<< "\t";
}
else
{
segment_term << jbterms[j].word;
}
}
std::cerr << segment_term.str() << endl; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .str() 就是得到流的字符串。