Splitting a string
<p>I have this code to split a string.  For some reason, it just sits there doing nothing.  I am not sure what the problem is.  By the way, <code>delim = ' '</code> here.</p>

<pre><code>vector&lt;string&gt; split( const string &amp;str, const char &amp;delim )
{
    typedef string::const_iterator iter;

    iter beg = str.begin();

    vector&lt;string&gt; tokens;

    while(beg != str.end())
    {
     iter temp = find(beg, str.end(), delim);
     if(beg != str.end())
      tokens.push_back(string(beg, temp));
     beg = temp;
    }

    return tokens;
}
</code></pre>
