title: Remove input from an output stream
body: <p>I want to use <code>std::copy</code> and <code>std::ostream_iterator</code> to print out the string within a <code>vector</code> as a coma separated list between parenthesis. So I have to deal with the issue of removing the <code>", "</code> after the last element.</p>
  
  <p>I have tried <a href="http://ideone.com/78kJEw" rel="nofollow">this</a>:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;string&gt;
  #include &lt;sstream&gt;
  #include &lt;iterator&gt;
  
  int main() {
  
      std::vector&lt;std::string&gt; v;
      v.push_back("a");
      v.push_back("b");
      v.push_back("c");
  
      std::stringstream os;
      os &lt;&lt; '(';
      std::copy(v.begin(), v.end(), std::ostream_iterator&lt;std::string&gt;(os, ", "));
      os.seekp(-2, std::ios_base::cur);
      os &lt;&lt; ')';
  
      std::cout &lt;&lt; os.str() &lt;&lt; ".";
  
      return 0;
  }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>(a, b, c) .
           ^
  </code></pre>
  
  <p>But the output I get has an extra white space character after the closing parenthesis, because <code>seekp</code> just moves the writing position but doesn't remove the written characters.</p>
  
  <p>Is there a way to remove that last character or write an EOF?</p>