c++ boost split string <p>I am using the <code>boost::split</code> method to split a string as this:</p> <p>I first make sure to include the correct header to have access to <code>boost::split</code>:</p> <pre><code>#include &lt;boost/algorithm/string.hpp&gt; </code></pre> <p>then:</p> <pre><code>vector&lt;string&gt; strs; boost::split(strs,line,boost::is_any_of("\t")); </code></pre> <p>and the line is like</p> <pre><code> "test test2 test3" </code></pre> <p>This is how I consume the result string vector:</p> <pre><code>void printstrs(vector&lt;string&gt; strs){ for(vector&lt;string&gt;::iterator it = strs.begin();it!=strs.end();++it){ cout&lt;&lt;*it&lt;&lt; "-------"; } cout&lt;&lt;endl; } </code></pre> <p>But why in the result <code>strs</code> I only get <code>"test2"</code> and <code>"test3"</code>, shouldn't be <code>"test"</code>, <code>"test2"</code> and <code>"test3"</code>, there are <code>\t</code> (tab) in the string.</p> <p><strong>Updated Apr 24th, 2011:</strong> It seemed after I changed one line of code at <code>printstrs</code> I can see the first string. I changed </p> <pre><code>cout&lt;&lt;*it&lt;&lt; "-------"; </code></pre> <p>to </p> <pre><code>cout&lt;&lt;*it&lt;&lt;endl; </code></pre> <p>And it seemed <code>"-------"</code> covered the first string somehow.</p>