<?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[Run time check failure]]></title><description><![CDATA[<p>Beim Ende des Durchlaufes öffnet sich ein neues Fenster mit dem Hinweis:<br />
&quot;Debug Error<br />
Run Time Check Failure #2 - stack around the variable ´funktionswerte´ was corrupted.&quot;<br />
Kann mir jemand netterweise kurz erklären, was ich falsch gemacht habe? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /> Danke.</p>
<pre><code class="language-cpp">// Aufg1i.cpp : Definiert den Einstiegspunkt für die Konsolenanwendung.
// Es sei die Funktion y=mx+n mit m=2 und n=-5. Die Funktionswerte von 0-20 sollen in einem Array gespeichert werden. 

#include &quot;stdafx.h&quot;
#include &lt;iostream&gt;
using namespace std;

int main()
{
	cout &lt;&lt; &quot;Ausgabe der Funktionswerte.&quot;
	&lt;&lt;endl;

	int funktionswerte [20];
	int x;

	for( int x = 0; x &lt;= 20; x++)
	{
	funktionswerte [x]=(2*x -5);
	cout &lt;&lt; funktionswerte[x]
	&lt;&lt;endl;
	}
	return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/183195/run-time-check-failure</link><generator>RSS for Node</generator><lastBuildDate>Wed, 23 Sep 2026 04:20:43 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/183195.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 02 Jun 2007 17:17:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Run time check failure on Sat, 02 Jun 2007 17:17:00 GMT]]></title><description><![CDATA[<p>Beim Ende des Durchlaufes öffnet sich ein neues Fenster mit dem Hinweis:<br />
&quot;Debug Error<br />
Run Time Check Failure #2 - stack around the variable ´funktionswerte´ was corrupted.&quot;<br />
Kann mir jemand netterweise kurz erklären, was ich falsch gemacht habe? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /> Danke.</p>
<pre><code class="language-cpp">// Aufg1i.cpp : Definiert den Einstiegspunkt für die Konsolenanwendung.
// Es sei die Funktion y=mx+n mit m=2 und n=-5. Die Funktionswerte von 0-20 sollen in einem Array gespeichert werden. 

#include &quot;stdafx.h&quot;
#include &lt;iostream&gt;
using namespace std;

int main()
{
	cout &lt;&lt; &quot;Ausgabe der Funktionswerte.&quot;
	&lt;&lt;endl;

	int funktionswerte [20];
	int x;

	for( int x = 0; x &lt;= 20; x++)
	{
	funktionswerte [x]=(2*x -5);
	cout &lt;&lt; funktionswerte[x]
	&lt;&lt;endl;
	}
	return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1297260</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1297260</guid><dc:creator><![CDATA[Flugsie]]></dc:creator><pubDate>Sat, 02 Jun 2007 17:17:00 GMT</pubDate></item><item><title><![CDATA[Reply to Run time check failure on Sat, 02 Jun 2007 17:26:13 GMT]]></title><description><![CDATA[<p>Mach mal das Array 21 Elemente gross. Und x musst du nicht zusätzlich ausserhalb des Schleifenkopfs definieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1297266</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1297266</guid><dc:creator><![CDATA[__Stefan__]]></dc:creator><pubDate>Sat, 02 Jun 2007 17:26:13 GMT</pubDate></item><item><title><![CDATA[Reply to Run time check failure on Sat, 02 Jun 2007 18:23:16 GMT]]></title><description><![CDATA[<p>Jetzt sieht es zwar schöner aus, aber die Fehlermeldung ist leider noch aktuell.<br />
Eine andere Frage: Wenn ich die Anzahl der negativen Funktionswerte bspw.<br />
zählen will, mit welchem Ausdruck muss ich mein bestehendes Programm erweitern?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1297301</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1297301</guid><dc:creator><![CDATA[Flugsie]]></dc:creator><pubDate>Sat, 02 Jun 2007 18:23:16 GMT</pubDate></item><item><title><![CDATA[Reply to Run time check failure on Sat, 02 Jun 2007 18:39:08 GMT]]></title><description><![CDATA[<p>Flugsie schrieb:</p>
<blockquote>
<p>Jetzt sieht es zwar schöner aus, aber die Fehlermeldung ist leider noch aktuell.<br />
Eine andere Frage: Wenn ich die Anzahl der negativen Funktionswerte bspw.<br />
zählen will, mit welchem Ausdruck muss ich mein bestehendes Programm erweitern?</p>
</blockquote>
<p>Nur falls es aus der ersten Antwort nicht klar wurde.</p>
<p>Du legst ein Array mit 20 (zwanzig) elementen an.</p>
<pre><code class="language-cpp">int funktionswerte [20];
</code></pre>
<p>dann machst Du eine chleife mit 21 (Einundzwanzig) Durchläufen:</p>
<pre><code class="language-cpp">for( int x = 0; x &lt;= 20; x++)
</code></pre>
<p>und greifst mit x auf die elemente des Arrays zu. da 21 &gt; als 20 ist, knallt das beim letzten Schleifendurchlauf dann durch.</p>
<p>Warum 21?</p>
<p>Nun, das erste Element hat den Index 0, das zweite Element den Index 1 usw. Demnach hat das zwanzigste Element den Index 19 und nicht 20...</p>
<p>Die Schleife muß also lauten:</p>
<pre><code class="language-cpp">for( int x = 0; x &lt; 20; x++)
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1297319</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1297319</guid><dc:creator><![CDATA[iksja]]></dc:creator><pubDate>Sat, 02 Jun 2007 18:39:08 GMT</pubDate></item><item><title><![CDATA[Reply to Run time check failure on Sat, 02 Jun 2007 18:44:14 GMT]]></title><description><![CDATA[<p>Jupp, logisch, [20] zu [21] ändern. Das ich auch immer alles übersehen muss...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1297322</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1297322</guid><dc:creator><![CDATA[Flugsie]]></dc:creator><pubDate>Sat, 02 Jun 2007 18:44:14 GMT</pubDate></item><item><title><![CDATA[Reply to Run time check failure on Sun, 03 Jun 2007 14:39:44 GMT]]></title><description><![CDATA[<p>musst du nicht, schließlich gibt es dazu entsprechende Werkzeuge (Stichwort statistische Codeanalyse), das spuckt z.B. Visual Studio raus:</p>
<blockquote>
<p>deleteme.cpp(14) : warning C4101: 'x' : unreferenced local variable<br />
deleteme.cpp(16) : warning C6246: Local declaration of 'x' hides declaration of the same name in outer scope. For additional information, see previous declaration at line '14' of 'deleteme.cpp': Lines: 14<br />
deleteme.cpp(18) : warning C6201: Index '20' is out of valid index range '0' to '19' for possibly stack allocated buffer 'funktionswerte'<br />
deleteme.cpp(19) : warning C6201: Index '20' is out of valid index range '0' to '19' for possibly stack allocated buffer 'funktionswerte'</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1297810</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1297810</guid><dc:creator><![CDATA[Superlexx]]></dc:creator><pubDate>Sun, 03 Jun 2007 14:39:44 GMT</pubDate></item></channel></rss>