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

  • 相关阅读:
    NYOJ 10 skiing DFS+DP
    51nod 1270 数组的最大代价
    HDU 4635 Strongly connected
    HDU 4612 Warm up
    POJ 3177 Redundant Paths
    HDU 1629 迷宫城堡
    uva 796
    uva 315
    POJ 3180 The Cow Prom
    POJ 1236 Network of Schools
  • 原文地址:https://www.cnblogs.com/xinping-study/p/12215606.html
Copyright © 2011-2022 走看看