<?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[Programm wird fehlerfrei kompiliert, stürzt aber ab]]></title><description><![CDATA[<p>Ich habe ein Programm geschrieben, in dem ein Inventar erschaffen wird, welches mit Gegenständen der Struktur &quot;Gegenstand&quot; belegt werden kann. Dieses Programm wird problemlos kompiliert, stürzt aber beim Programmstart ab.</p>
<p>Kann man da im Quelltext was richten?</p>
<pre><code>#include &lt;iostream&gt;

using namespace std;

struct Gegenstand
{
	string Typ;
	string Name;
	string Wertbeschreibung;
	int Wert;
};

int main()
{
	Gegenstand Inventar[10];

	for(int i = 0; i &lt;= 10; i++)
	{
		Inventar[i].Typ = &quot;leer&quot;;
	}

	// Brot
	Gegenstand Brot;
	Brot.Typ = &quot;Lebensmittel&quot;;
	Brot.Name = &quot;Brot&quot;;
	Brot.Wertbeschreibung = &quot;Lebensenergie&quot;;
	Brot.Wert = 10;

    Inventar[0] = Brot;

    for (int i = 0;i &lt;= 10 ; i++)
    {
        if (Inventar[i].Typ != &quot;leer&quot;)
        {
        	cout &lt;&lt; Inventar[i].Typ &lt;&lt; &quot; - &quot; &lt;&lt; Inventar[i].Name &lt;&lt; &quot;: &quot; &lt;&lt; Inventar[i].Wertbeschreibung &lt;&lt; &quot; + &quot; &lt;&lt; Inventar[i].Wert &lt;&lt; '\n';
		}

		else
		{
			cout &lt;&lt; &quot;leer&quot; &lt;&lt; '\n';
		}	
	}
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/336849/programm-wird-fehlerfrei-kompiliert-stürzt-aber-ab</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Apr 2026 20:36:26 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/336849.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 20 Feb 2016 09:53:53 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Programm wird fehlerfrei kompiliert, stürzt aber ab on Sat, 20 Feb 2016 09:53:53 GMT]]></title><description><![CDATA[<p>Ich habe ein Programm geschrieben, in dem ein Inventar erschaffen wird, welches mit Gegenständen der Struktur &quot;Gegenstand&quot; belegt werden kann. Dieses Programm wird problemlos kompiliert, stürzt aber beim Programmstart ab.</p>
<p>Kann man da im Quelltext was richten?</p>
<pre><code>#include &lt;iostream&gt;

using namespace std;

struct Gegenstand
{
	string Typ;
	string Name;
	string Wertbeschreibung;
	int Wert;
};

int main()
{
	Gegenstand Inventar[10];

	for(int i = 0; i &lt;= 10; i++)
	{
		Inventar[i].Typ = &quot;leer&quot;;
	}

	// Brot
	Gegenstand Brot;
	Brot.Typ = &quot;Lebensmittel&quot;;
	Brot.Name = &quot;Brot&quot;;
	Brot.Wertbeschreibung = &quot;Lebensenergie&quot;;
	Brot.Wert = 10;

    Inventar[0] = Brot;

    for (int i = 0;i &lt;= 10 ; i++)
    {
        if (Inventar[i].Typ != &quot;leer&quot;)
        {
        	cout &lt;&lt; Inventar[i].Typ &lt;&lt; &quot; - &quot; &lt;&lt; Inventar[i].Name &lt;&lt; &quot;: &quot; &lt;&lt; Inventar[i].Wertbeschreibung &lt;&lt; &quot; + &quot; &lt;&lt; Inventar[i].Wert &lt;&lt; '\n';
		}

		else
		{
			cout &lt;&lt; &quot;leer&quot; &lt;&lt; '\n';
		}	
	}
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2487959</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2487959</guid><dc:creator><![CDATA[Dexter1997]]></dc:creator><pubDate>Sat, 20 Feb 2016 09:53:53 GMT</pubDate></item><item><title><![CDATA[Reply to Programm wird fehlerfrei kompiliert, stürzt aber ab on Sat, 20 Feb 2016 09:55:56 GMT]]></title><description><![CDATA[<p>Bleib halt innerhalb der Array-Grenzen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2487961</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2487961</guid><dc:creator><![CDATA[_Richter]]></dc:creator><pubDate>Sat, 20 Feb 2016 09:55:56 GMT</pubDate></item><item><title><![CDATA[Reply to Programm wird fehlerfrei kompiliert, stürzt aber ab on Sat, 20 Feb 2016 10:00:35 GMT]]></title><description><![CDATA[<p>Zähl mal von 0 bis 10 und mach bei jeder Zahl, die du sagst, einen Strich auf ein Blatt Papier. Wie viele Striche hast du dann insgesamt gemacht?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2487962</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2487962</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Sat, 20 Feb 2016 10:00:35 GMT</pubDate></item><item><title><![CDATA[Reply to Programm wird fehlerfrei kompiliert, stürzt aber ab on Sat, 20 Feb 2016 12:32:17 GMT]]></title><description><![CDATA[<p>Und als Folgerung aus diesem Fehler: benutze std::vector mit Iteratoren und stecke keine &quot;leeren&quot; Gegenstände hinein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2487969</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2487969</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Sat, 20 Feb 2016 12:32:17 GMT</pubDate></item><item><title><![CDATA[Reply to Programm wird fehlerfrei kompiliert, stürzt aber ab on Sat, 20 Feb 2016 12:46:24 GMT]]></title><description><![CDATA[<p>Vielen Dank für eure Antworten, das Problem bestand tatsächlich, darin, daß ich einem Element, was nicht existiert, einen Wert zuweisen wollte. Nun funktioniert es!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2487970</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2487970</guid><dc:creator><![CDATA[Dexter1997]]></dc:creator><pubDate>Sat, 20 Feb 2016 12:46:24 GMT</pubDate></item><item><title><![CDATA[Reply to Programm wird fehlerfrei kompiliert, stürzt aber ab on Sun, 21 Feb 2016 07:41:48 GMT]]></title><description><![CDATA[<p>Ein paar Tipps, zum nachschlagen:<br />
<code>range-based-for</code><br />
<code>std::vector</code><br />
<code>overloading &gt;&gt; and &lt;&lt; operator</code><br />
<code>RAII/(default) constructor</code></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2488021</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2488021</guid><dc:creator><![CDATA[HarteWare]]></dc:creator><pubDate>Sun, 21 Feb 2016 07:41:48 GMT</pubDate></item><item><title><![CDATA[Reply to Programm wird fehlerfrei kompiliert, stürzt aber ab on Sun, 21 Feb 2016 10:00:21 GMT]]></title><description><![CDATA[<p>wenn er 0...10 statt 0...9 falsch macht, braucht er sich mit operator overloading und RAII gar nicht erst zu beschäftigen. Das kommt erst sehr viel später.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2488029</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2488029</guid><dc:creator><![CDATA[klassenmethode]]></dc:creator><pubDate>Sun, 21 Feb 2016 10:00:21 GMT</pubDate></item></channel></rss>