substr in c++ problem
<p>When I try to execute the program, the output is coming as expected for the first iteration. but for second iteration, out is not coming as expected...</p>

<pre><code>int main(){
        string insertBuffer;
        string valSep;
        valSep = ":";
        string configParamSep = "\r\n";
        int configParamSepSize = 2;
        string configParam;
        string::size_type mCPos = 0;
        string::size_type mCBeginPos = 0;
    int finished = 0;
    string one = "hai: yes";
    string two = "tension: no"; 
        insertBuffer = one + "\r\n" + two + "\r\n";

    cout&lt;&lt;"OUTPUT:"&lt;&lt;"\n";

        while (!finished){
                if( !(mCBeginPos &gt;= insertBuffer.length()) &amp;&amp; ((mCPos = insertBuffer.find(valSep,mCBeginPos)) != string::npos)){
                        configParam = insertBuffer.substr(mCBeginPos,mCPos);
                }else{
                        finished = 1;
                        break;
                }
        cout&lt;&lt;configParam&lt;&lt;"\n";
                mCBeginPos = mCBeginPos + insertBuffer.find(configParamSep,mCBeginPos) + configParamSepSize;
    }

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

<p>OUTPUT:</p>

<pre><code>hai
tension: no
</code></pre>

<p>But expected outpu is:-</p>

<pre><code>hai
tension
</code></pre>

<p>Any clue why this is happening?</p>
