terminate called throwing an exceptionAbort trap: 6
<p>I have the following code and when I compiled and went, I got following message</p>

<blockquote>
  <p>terminate called throwing an exceptionAbort trap: 6</p>
</blockquote>

<p>I looked for this ,but I was not able to understand this error message. Please tell me, what this error message means and how I fix the code.
Here is the code:</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;
using namespace std;

int main(){
    int n,r;
    while(cin&gt;&gt;n&gt;&gt;r){
        if(n==0&amp;&amp;r==0)break;
        string s;
        for(int i=0;i&lt;n;i++)
            s[i]='i';

        for(int i=0;i&lt;r;i++){
            int p,c;
            cin&gt;&gt;p&gt;&gt;c;
            string left=s.substr(p-1,p+c-1);
            string right=s.substr(0,p-2)+s.substr(p+c, (int)s.size());
            s=left+right;
        }
        cout &lt;&lt; (int)(s[0]-'0')+1 &lt;&lt; endl;
    }
        return 0;
}
</code></pre>

<p>compile with g++, on Mac OSX 10.7.4</p>
