zoukankan      html  css  js  c++  java
  • std::cerr << segment_term.str() << endl;

    <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<< " ";
    }
    else
    {
    segment_term << jbterms[j].word;
    }
    }
    std::cerr << segment_term.str() << endl;   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    .str()  就是得到流的字符串。

  • 相关阅读:
    钟国晨160809323(作业5)
    12
    11
    第九次
    8作业
    第七次作业
    6
    林昊5
    计算机网络原理与应用笔记 3/29
    计算机网络原理与应用笔记 3/22
  • 原文地址:https://www.cnblogs.com/xinping-study/p/12215606.html
Copyright © 2011-2022 走看看