How can I split a string in C++
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/236129/how-to-split-a-string">How to split a string?</a>  </p>
</blockquote>



<p>I have a string like this.</p>

<pre><code>a1,b1,a2,b2......
</code></pre>

<p>I want a vector of strings like this</p>

<pre><code>a[0] = "a1"
a[1] = "b1"
a[2] = "a2"
a[3] = "b2"
</code></pre>

<p>please help me!!</p>

<p>I am not a good programmer, is for a homework, and i only finds this</p>

<pre><code>string sentence = "Something,in,the,way,she,moves...";
istringstream iss(sentence);
copy(istream_iterator&lt;string&gt;(iss),
istream_iterator&lt;string&gt;(),
ostream_iterator&lt;string&gt;(cout, "\n"));

vector&lt;string&gt; tokens;
copy(istream_iterator&lt;string&gt;(iss),
istream_iterator&lt;string&gt;(),
back_inserter&lt;vector&lt;string&gt; &gt;(tokens));
</code></pre>

<p>but this only split the words separated by whitespaces.</p>
