use getline and while loop to split a string
<p>for example i have a string:</p>

<pre><code>string s = "apple | orange | kiwi";
</code></pre>

<p>and i searched and there is a way:</p>

<pre><code>stringstream stream(s);
string tok;
getline(stream, tok, '|');
</code></pre>

<p>but it only can return the first token "apple"
I wonder that is there any way so it can return an array of string?
Thank you.
Let assume that the string s may be changed. For exammple,  string s = "apple | orange | kiwi | berry";</p>
