码迷,mamicode.com
首页 > 其他好文 > 详细

std::cerr << segment_term.str() << endl;

时间:2020-01-19 21:54:36      阅读:88      评论:0      收藏:0      [点我收藏+]

标签:else   for   lse   turn   The   car   contents   std   previous   

<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()  就是得到流的字符串。

 

std::cerr << segment_term.str() << endl;

标签:else   for   lse   turn   The   car   contents   std   previous   

原文地址:https://www.cnblogs.com/xinping-study/p/12215606.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!