Deleting 10 first chars from c++ string
<p>I'm currently failing at an actually very simple task, I want to delete the first 10 chars from a string. I tried diffrent mehtods now but I always get an instant crash when I theoretically should get my wanted result.</p>

<p>The string size is changing dynamically, it gets fed by an RSS feed every 10 seconds.</p>

<p>So what I'm currently trying to use is:</p>

<pre><code>#include &lt;string&gt;

string str = imgURL;
int urlLength = imgURL.length();
urlLength = urlLength-10;
str.erase (str.begin(), str.end()-urlLength);
imgURL = str;
</code></pre>

<p>This gives me an instant crash, however when I use:</p>

<pre><code>str.erase (str.begin(), str.end()-35);
</code></pre>

<p>which is the value that the int urlLength has after urlLength-10, I get no crash and the URL is cut properly.</p>

<p>The raw string from the rss feed: <code>&lt;img src="http://imgs.xkcd.com/comics/sky.png" title="I dropped a bird and I didn't hear it hit bottom." alt="I dropped a bird and I didn't hear it hit bottom." /&gt;</code></p>

<p>What it looks like in the string: <code>&lt;img src="http://imgs.xkcd.com/comics/sky.png</code></p>

<p>What I want it too look like: <code>http://imgs.xkcd.com/comics/sky.png</code></p>

<p>I could have easily used SplitString but this also gives me crashes for no apperent reasons when I use an index higher than 0.
I don't need to use this solution, it just seemed as the easiest one for me.</p>
