title: How to use stringstream to separate comma separated strings
body: <p>I've got the following code:</p>
  <pre><code>std::string str = &quot;abc def,ghi&quot;;
  std::stringstream ss(str);
  
  string token;
  
  while (ss &gt;&gt; token)
  {
      printf(&quot;%s\n&quot;, token.c_str());
  }
  </code></pre>
  <p>The output is:</p>
  <blockquote>
  <p>abc<br />
  def,ghi</p>
  </blockquote>
  <p>So the <code>stringstream::&gt;&gt;</code> operator can separate strings by space but not by comma. Is there anyway to modify the above code so that I can get the following result?</p>
  <blockquote>
  <p><strong>input</strong>: &quot;abc,def,ghi&quot;</p>
  <p><strong>output</strong>:<br />
  abc<br />
  def<br />
  ghi</p>
  </blockquote>