<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Debug Assertion Failed &#x2F; Vector Subscript out of range]]></title><description><![CDATA[<p>Hallo,</p>
<p>Expression: Vector Subscript out of range Diesen Runtime Fehler bekomme ich.</p>
<p>Programmiere mir grade Pacman mit der SDL. Es läuft auch soweit bloß nach mehreren Sekunden spielen kommt der Runtime Fehler. Ich bin das mal mit dem Debugger durchgegegangen und an dieser Stelle gibt er mir einen Fehler:</p>
<pre><code>bool XFontMap::Initialize(char* File, int Pointsize, int Bit) {
FontControl = TTF_OpenFont(File, Pointsize);

if(FontControl == NULL) {
cerr &lt;&lt; &quot;XFontMap::Initialize &gt; File not found '&quot; &lt;&lt; File &lt;&lt; &quot;'\n&quot;;
return false;
}

char tempChar[1];

int tempWidth = 0;

for(int i = 0;i &lt; 255;i++) {
sprintf(tempChar, &quot;%c&quot;, (char)i);
TTF_SizeText(FontControl, tempChar, &amp;tempWidth, NULL);

if(tempWidth &gt; CharWidth) CharWidth = tempWidth;

}

CharHeight = TTF_FontHeight(FontControl);

Surf_FontMap = SDL_CreateRGBSurface(SDL_HWSURFACE, CharWidth, CharHeight * 255, Bit, RMASK, GMASK, BMASK, AMASK);
Surf_FontMap = SDL_DisplayFormat(Surf_FontMap);

ClearImage(Surf_FontMap, SDL_MapRGB(Surf_FontMap-&gt;format, FontBGColor.r, FontBGColor.g, FontBGColor.b));

return true;
};
</code></pre>
<p>Am Ende dieser Funktion sagt er mir:<br />
Run-Time Check Failure #2 - Stack around the variable 'tempChar' was corrupted.</p>
<p>Finde den Fehler im Moment einfach nicht.</p>
<p>MfG<br />
Rennmoehre</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/314368/debug-assertion-failed-vector-subscript-out-of-range</link><generator>RSS for Node</generator><lastBuildDate>Sat, 01 Aug 2026 08:55:37 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/314368.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 28 Feb 2013 14:53:25 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Debug Assertion Failed &#x2F; Vector Subscript out of range on Thu, 28 Feb 2013 14:53:25 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Expression: Vector Subscript out of range Diesen Runtime Fehler bekomme ich.</p>
<p>Programmiere mir grade Pacman mit der SDL. Es läuft auch soweit bloß nach mehreren Sekunden spielen kommt der Runtime Fehler. Ich bin das mal mit dem Debugger durchgegegangen und an dieser Stelle gibt er mir einen Fehler:</p>
<pre><code>bool XFontMap::Initialize(char* File, int Pointsize, int Bit) {
FontControl = TTF_OpenFont(File, Pointsize);

if(FontControl == NULL) {
cerr &lt;&lt; &quot;XFontMap::Initialize &gt; File not found '&quot; &lt;&lt; File &lt;&lt; &quot;'\n&quot;;
return false;
}

char tempChar[1];

int tempWidth = 0;

for(int i = 0;i &lt; 255;i++) {
sprintf(tempChar, &quot;%c&quot;, (char)i);
TTF_SizeText(FontControl, tempChar, &amp;tempWidth, NULL);

if(tempWidth &gt; CharWidth) CharWidth = tempWidth;

}

CharHeight = TTF_FontHeight(FontControl);

Surf_FontMap = SDL_CreateRGBSurface(SDL_HWSURFACE, CharWidth, CharHeight * 255, Bit, RMASK, GMASK, BMASK, AMASK);
Surf_FontMap = SDL_DisplayFormat(Surf_FontMap);

ClearImage(Surf_FontMap, SDL_MapRGB(Surf_FontMap-&gt;format, FontBGColor.r, FontBGColor.g, FontBGColor.b));

return true;
};
</code></pre>
<p>Am Ende dieser Funktion sagt er mir:<br />
Run-Time Check Failure #2 - Stack around the variable 'tempChar' was corrupted.</p>
<p>Finde den Fehler im Moment einfach nicht.</p>
<p>MfG<br />
Rennmoehre</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2302948</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2302948</guid><dc:creator><![CDATA[Rennmoehre]]></dc:creator><pubDate>Thu, 28 Feb 2013 14:53:25 GMT</pubDate></item><item><title><![CDATA[Reply to Debug Assertion Failed &#x2F; Vector Subscript out of range on Thu, 28 Feb 2013 15:02:10 GMT]]></title><description><![CDATA[<p>sprintf(tempChar, &quot;%c&quot;, (char)i);</p>
<p>hier schreibst du 2 chars in tempChar rein, da passt aber nur 1 char rein.</p>
<p>Du kannst dir hier sprintf auch sparen (printf solltest du in C++ sowieso nicht verwenden) und einfach:</p>
<pre><code class="language-cpp">char tempChar[2]={0};
for(...) {
  tempChar[0]=c;
}
</code></pre>
<p>machen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2302953</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2302953</guid><dc:creator><![CDATA[Shade Of Mine]]></dc:creator><pubDate>Thu, 28 Feb 2013 15:02:10 GMT</pubDate></item><item><title><![CDATA[Reply to Debug Assertion Failed &#x2F; Vector Subscript out of range on Thu, 28 Feb 2013 15:48:31 GMT]]></title><description><![CDATA[<p>Ok das hat den Fehler behoben danke <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /> bekomme trotzdem noch nen Assertion Fail beim spielen kann aber diesmal die Stelle nicht finden <sub>.</sub></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2302973</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2302973</guid><dc:creator><![CDATA[Rennmoehre]]></dc:creator><pubDate>Thu, 28 Feb 2013 15:48:31 GMT</pubDate></item><item><title><![CDATA[Reply to Debug Assertion Failed &#x2F; Vector Subscript out of range on Thu, 12 Jun 2014 03:24:54 GMT]]></title><description><![CDATA[<p>...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2302974</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2302974</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Thu, 12 Jun 2014 03:24:54 GMT</pubDate></item></channel></rss>