<?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 stürzt ohne Fehlermeldung ab]]></title><description><![CDATA[<p>Ich übe mich gerade in dynamischen Datenstrukturen und habe eine ADT erschaffen mit einer doppel verketteten Liste als Element.</p>
<p>Nachdem ich 50 Einträge in die Liste geschrieben habe, möchte ich diverse Zahlen herauslöschen.<br />
Leider stürzt das Programm jedesmal unerwartet ab, obwohl ich keine Fehlermeldungen beim Compilieren bekomme</p>
<p>Hier der Code:</p>
<p>Die Klasse</p>
<pre><code class="language-cpp">#ifndef INTLIST_H_INCLUDED
//#define NULL 0
#define INTLIST_H_INCLUDED

class intList
{
    struct intElem
    {
        int info;
        intElem* pred;
        intElem* succ;
    };

    intElem* head;

    public:

    intList();
    ~intList();
    intElem* request() const {
        intElem* help=head;
        if(!help)
            return 0;
        int i=0;
        while(help)
        {
            help=help-&gt;succ;
            i++;
        }
        if(i&gt;1000)
            return 0;
    }

    void free(intElem*);//gibt den speicher für el wieder frei
    void insert(int);//geordnetes einfügen eines wertes
    bool exists(int);//test auf vorhandensei eines elements
    void remove(int);//entfernt wert aus der liste
    void readList();//liest listenelemente aus
};

#endif // INTLIST_H_INCLUDED

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

intList::intList() {
    head=NULL;
}

void intList::insert(int n){
    intElem* temp=new intElem;
    temp-&gt;info=n;
    if(!head)
    {
        temp-&gt;pred=NULL;
        temp-&gt;succ=NULL;
        head=temp;
    }
    else
    {
        intElem* help=head;
        while(help-&gt;succ &amp;&amp; help-&gt;succ-&gt;info&lt;n)
            help=help-&gt;succ;
        if(help-&gt;succ)
        {
            temp-&gt;succ=help-&gt;succ;
            help-&gt;succ-&gt;pred=temp;
            help-&gt;succ=temp;
            temp-&gt;pred=help;
        }
        else
        {
            help-&gt;succ=temp;
            temp-&gt;pred=help;
            temp-&gt;succ=NULL;
        }
    }
}

void intList::readList()
{
    intElem* help=head;
    while(help)
    {
        cout&lt;&lt;help-&gt;info&lt;&lt;endl;
        help=help-&gt;succ;
    }
}

void intList::free(intElem* el)
{
    el-&gt;pred-&gt;succ=el-&gt;succ;
    el-&gt;succ-&gt;pred=el-&gt;pred;
    delete el;
}

intList::~intList()
{
    intElem* help=head;
    while(help)
    {
        head=head-&gt;succ;
        delete help;
        help=head;
    }
}

void intList::remove(int n)
{
    intElem* help=head;
    while(help &amp;&amp; !(help-&gt;info&gt;n))
    {
        if(help-&gt;info==n)
        {
            if(!help-&gt;pred)
            {
                intElem* temp=help;
                help=help-&gt;succ;
                delete temp;
                head=help;
            }
            if(!help-&gt;succ)
            {
                intElem* temp=help;
                help-&gt;pred-&gt;succ=NULL;
                delete temp;
            }
            else
            {
                intElem* temp=help;
                help-&gt;pred-&gt;succ=help-&gt;succ;
                help-&gt;succ-&gt;pred=help-&gt;pred;
                delete temp;
            }

        }
        help=help-&gt;succ;
    }
}

bool intList::exists(int n)
{
    intElem* help=head;
    while(help)
    {
        if(help-&gt;info==n)
            return true;
        help=help-&gt;succ;
    }
    return false;
}
</code></pre>
<p>und hier die Main-Funktion</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
#include &quot;intList.h&quot;
using namespace std;

int main()
{
    intList bumm;
    for(int i=2;i&lt;51;i++)
    {
        bumm.insert(i);

    }
    bumm.readList();
    cin.get();
    int k=0;
    string jo=&quot;&quot;;
    for(k=2;k&lt;=50;k++) {
        if(k%2==0)
            bumm.remove(k);
    }
    for(k=2;k&lt;=50;k++) {
        if(k%3==0)
            bumm.remove(k);
    }
    for(k=2;k&lt;=50;k++) {
        if(k%5==0)
            bumm.remove(k);
    }
    bumm.readList();
/*    do
    {
    cout&lt;&lt;&quot;loeschen k=&quot;;
    cin&gt;&gt;k;
    bumm.remove(k);
    bumm.readList();
    cout&lt;&lt;endl&lt;&lt;&quot; nochmal? j n&quot;&lt;&lt;endl;
    cin&gt;&gt;jo;
    }while(jo[0]=='j');
 */ return 0;
}
</code></pre>
<p>ich wäre euch sehr dankbar, wenn ihr mir meine(n) Fehler aufschlüsselt, da ich langsam verzweifel <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="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/287151/programm-stürzt-ohne-fehlermeldung-ab</link><generator>RSS for Node</generator><lastBuildDate>Thu, 20 Aug 2026 14:40:45 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/287151.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 23 May 2011 19:52:29 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Programm stürzt ohne Fehlermeldung ab on Mon, 23 May 2011 19:54:55 GMT]]></title><description><![CDATA[<p>Ich übe mich gerade in dynamischen Datenstrukturen und habe eine ADT erschaffen mit einer doppel verketteten Liste als Element.</p>
<p>Nachdem ich 50 Einträge in die Liste geschrieben habe, möchte ich diverse Zahlen herauslöschen.<br />
Leider stürzt das Programm jedesmal unerwartet ab, obwohl ich keine Fehlermeldungen beim Compilieren bekomme</p>
<p>Hier der Code:</p>
<p>Die Klasse</p>
<pre><code class="language-cpp">#ifndef INTLIST_H_INCLUDED
//#define NULL 0
#define INTLIST_H_INCLUDED

class intList
{
    struct intElem
    {
        int info;
        intElem* pred;
        intElem* succ;
    };

    intElem* head;

    public:

    intList();
    ~intList();
    intElem* request() const {
        intElem* help=head;
        if(!help)
            return 0;
        int i=0;
        while(help)
        {
            help=help-&gt;succ;
            i++;
        }
        if(i&gt;1000)
            return 0;
    }

    void free(intElem*);//gibt den speicher für el wieder frei
    void insert(int);//geordnetes einfügen eines wertes
    bool exists(int);//test auf vorhandensei eines elements
    void remove(int);//entfernt wert aus der liste
    void readList();//liest listenelemente aus
};

#endif // INTLIST_H_INCLUDED

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

intList::intList() {
    head=NULL;
}

void intList::insert(int n){
    intElem* temp=new intElem;
    temp-&gt;info=n;
    if(!head)
    {
        temp-&gt;pred=NULL;
        temp-&gt;succ=NULL;
        head=temp;
    }
    else
    {
        intElem* help=head;
        while(help-&gt;succ &amp;&amp; help-&gt;succ-&gt;info&lt;n)
            help=help-&gt;succ;
        if(help-&gt;succ)
        {
            temp-&gt;succ=help-&gt;succ;
            help-&gt;succ-&gt;pred=temp;
            help-&gt;succ=temp;
            temp-&gt;pred=help;
        }
        else
        {
            help-&gt;succ=temp;
            temp-&gt;pred=help;
            temp-&gt;succ=NULL;
        }
    }
}

void intList::readList()
{
    intElem* help=head;
    while(help)
    {
        cout&lt;&lt;help-&gt;info&lt;&lt;endl;
        help=help-&gt;succ;
    }
}

void intList::free(intElem* el)
{
    el-&gt;pred-&gt;succ=el-&gt;succ;
    el-&gt;succ-&gt;pred=el-&gt;pred;
    delete el;
}

intList::~intList()
{
    intElem* help=head;
    while(help)
    {
        head=head-&gt;succ;
        delete help;
        help=head;
    }
}

void intList::remove(int n)
{
    intElem* help=head;
    while(help &amp;&amp; !(help-&gt;info&gt;n))
    {
        if(help-&gt;info==n)
        {
            if(!help-&gt;pred)
            {
                intElem* temp=help;
                help=help-&gt;succ;
                delete temp;
                head=help;
            }
            if(!help-&gt;succ)
            {
                intElem* temp=help;
                help-&gt;pred-&gt;succ=NULL;
                delete temp;
            }
            else
            {
                intElem* temp=help;
                help-&gt;pred-&gt;succ=help-&gt;succ;
                help-&gt;succ-&gt;pred=help-&gt;pred;
                delete temp;
            }

        }
        help=help-&gt;succ;
    }
}

bool intList::exists(int n)
{
    intElem* help=head;
    while(help)
    {
        if(help-&gt;info==n)
            return true;
        help=help-&gt;succ;
    }
    return false;
}
</code></pre>
<p>und hier die Main-Funktion</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
#include &quot;intList.h&quot;
using namespace std;

int main()
{
    intList bumm;
    for(int i=2;i&lt;51;i++)
    {
        bumm.insert(i);

    }
    bumm.readList();
    cin.get();
    int k=0;
    string jo=&quot;&quot;;
    for(k=2;k&lt;=50;k++) {
        if(k%2==0)
            bumm.remove(k);
    }
    for(k=2;k&lt;=50;k++) {
        if(k%3==0)
            bumm.remove(k);
    }
    for(k=2;k&lt;=50;k++) {
        if(k%5==0)
            bumm.remove(k);
    }
    bumm.readList();
/*    do
    {
    cout&lt;&lt;&quot;loeschen k=&quot;;
    cin&gt;&gt;k;
    bumm.remove(k);
    bumm.readList();
    cout&lt;&lt;endl&lt;&lt;&quot; nochmal? j n&quot;&lt;&lt;endl;
    cin&gt;&gt;jo;
    }while(jo[0]=='j');
 */ return 0;
}
</code></pre>
<p>ich wäre euch sehr dankbar, wenn ihr mir meine(n) Fehler aufschlüsselt, da ich langsam verzweifel <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="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2067619</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2067619</guid><dc:creator><![CDATA[cpp_nap]]></dc:creator><pubDate>Mon, 23 May 2011 19:54:55 GMT</pubDate></item><item><title><![CDATA[Reply to Programm stürzt ohne Fehlermeldung ab on Mon, 23 May 2011 20:05:19 GMT]]></title><description><![CDATA[<p>Warst du schon im Debugger?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2067626</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2067626</guid><dc:creator><![CDATA[EOutOfResources]]></dc:creator><pubDate>Mon, 23 May 2011 20:05:19 GMT</pubDate></item><item><title><![CDATA[Reply to Programm stürzt ohne Fehlermeldung ab on Mon, 23 May 2011 20:13:12 GMT]]></title><description><![CDATA[<p>Also erst mal ist es ja klar dass der Compiler dir keine fehlermeldung gibt, wenn das Programm kompiliert ist. Würde er nen Fehler melden, würde er au nicht kompilieren;-)<br />
Zu deinem Programm, da ich leider gerade nur mein smartphone zur<br />
hand habe, habe ich keine Lust alles zu durchforsten, aber jetzt wäre für dich der perfekte Zeitpunkt um den Umgang mit einem <strong>Debugger</strong> zu erlernen.<br />
Aber es wird sich sicherlich gleich auch jemand finden der dir genaueres sagen kann.</p>
<p>LG freeG</p>
<p>Edit:</p>
<p>EOutOfResources schrieb:</p>
<blockquote>
<p>Warst du schon im Debugger?</p>
</blockquote>
<p>Gleicher Gedanke, dauert bloß so ewig mim Handy <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2067628</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2067628</guid><dc:creator><![CDATA[fr33g]]></dc:creator><pubDate>Mon, 23 May 2011 20:13:12 GMT</pubDate></item><item><title><![CDATA[Reply to Programm stürzt ohne Fehlermeldung ab on Mon, 23 May 2011 20:09:50 GMT]]></title><description><![CDATA[<blockquote>
<pre><code class="language-cpp">if(!help-&gt;pred) 
            { 
                intElem* temp=help; 
                help=help-&gt;succ; 
                delete temp; 
                head=help; 
            } 
            if(!help-&gt;succ) 
            { 
                intElem* temp=help; 
                help-&gt;pred-&gt;succ=NULL; 
                delete temp; 
            } 
            else 
            { 
                intElem* temp=help; 
                help-&gt;pred-&gt;succ=help-&gt;succ; 
                help-&gt;succ-&gt;pred=help-&gt;pred; 
                delete temp; 
            }
</code></pre>
</blockquote>
<p>Schau dir mal an, welche der Bedingungen hier erfüllt sind, wenn du das auf das Kopf-Element anwendest (sowas nennt sich &quot;double delete&quot; und gehört zu undefiniertem Verhalten).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2067631</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2067631</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 23 May 2011 20:09:50 GMT</pubDate></item></channel></rss>