<?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[Linked List]]></title><description><![CDATA[<p>Moin zusammen,</p>
<p>Ich habe gerade begonnen mich ein bissie mit verketteten Listen auseinander zu setzen.<br />
Im ersten Anlauf hat alles funktioniert.<br />
Jetzt habe ich aber ein paar Sachen umgebaut. Das heisst ich gebe meiner Funktion NodeEinfuegen() auch den Anfang und das Ende mit.</p>
<p>-&gt; NODE_PTR NodeEinfuegen(NODE_PTR *start,NODE_PTR *ende, int wert)</p>
<p>soweit so gut, aber eine Zeile kriege ich nicht hin<br />
*start-&gt;next =neuerNode;</p>
<p>Ich krieg immer den Fehler: left of &quot;-&gt;next&quot; must point to a class/struct/blah.</p>
<p>Wie muss ich die Zeile schreiben dass es funktioniert? Ich hab schon überall * und &amp; und was mir sonst so eingefallen ist hingeschrieben... nix geht.</p>
<p>Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/145649/linked-list</link><generator>RSS for Node</generator><lastBuildDate>Thu, 03 Sep 2026 11:27:15 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/145649.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 30 Apr 2006 03:23:29 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Linked List on Sun, 30 Apr 2006 03:23:29 GMT]]></title><description><![CDATA[<p>Moin zusammen,</p>
<p>Ich habe gerade begonnen mich ein bissie mit verketteten Listen auseinander zu setzen.<br />
Im ersten Anlauf hat alles funktioniert.<br />
Jetzt habe ich aber ein paar Sachen umgebaut. Das heisst ich gebe meiner Funktion NodeEinfuegen() auch den Anfang und das Ende mit.</p>
<p>-&gt; NODE_PTR NodeEinfuegen(NODE_PTR *start,NODE_PTR *ende, int wert)</p>
<p>soweit so gut, aber eine Zeile kriege ich nicht hin<br />
*start-&gt;next =neuerNode;</p>
<p>Ich krieg immer den Fehler: left of &quot;-&gt;next&quot; must point to a class/struct/blah.</p>
<p>Wie muss ich die Zeile schreiben dass es funktioniert? Ich hab schon überall * und &amp; und was mir sonst so eingefallen ist hingeschrieben... nix geht.</p>
<p>Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1048053</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1048053</guid><dc:creator><![CDATA[noobiex]]></dc:creator><pubDate>Sun, 30 Apr 2006 03:23:29 GMT</pubDate></item><item><title><![CDATA[Reply to Linked List on Sun, 30 Apr 2006 04:53:15 GMT]]></title><description><![CDATA[<p>Lass den Stern doch einfach mal weg.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1048058</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1048058</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Sun, 30 Apr 2006 04:53:15 GMT</pubDate></item><item><title><![CDATA[Reply to Linked List on Sun, 30 Apr 2006 08:01:23 GMT]]></title><description><![CDATA[<p>oder schreib einen punkt anstatt des pfeils:</p>
<p>wie MFK meint:<br />
start-&gt;next =neuerNode;</p>
<p>oder<br />
*start.next=neuerNode;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1048089</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1048089</guid><dc:creator><![CDATA[XZ59]]></dc:creator><pubDate>Sun, 30 Apr 2006 08:01:23 GMT</pubDate></item><item><title><![CDATA[Reply to Linked List on Sun, 30 Apr 2006 08:57:43 GMT]]></title><description><![CDATA[<p>das wird nicht funktionieren:</p>
<p>XZ59 schrieb:</p>
<blockquote>
<p>*start.next=neuerNode;</p>
</blockquote>
<p><a href="http://cppreference.com/operator_precedence.html" rel="nofollow">http://cppreference.com/operator_precedence.html</a><br />
Der Derefenenzierungsoperator wird zu erst ausgeführt und dann kommt ein<br />
&quot; undeklared var error&quot; oder so ähnlich raus</p>
<pre><code class="language-cpp">pVar-&gt;blah()
</code></pre>
<p>is die kurzfoem für</p>
<pre><code class="language-cpp">(*pVar).blah()
</code></pre>
<p>Mfg Shade37337</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1048120</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1048120</guid><dc:creator><![CDATA[branleb]]></dc:creator><pubDate>Sun, 30 Apr 2006 08:57:43 GMT</pubDate></item><item><title><![CDATA[Reply to Linked List on Sun, 30 Apr 2006 09:56:41 GMT]]></title><description><![CDATA[<p>So einfach kannst du es dir nicht machen. Was machst du wenn durch das Einfügen einer Node du einen neuen Anfang oder ein neues Ende hast?</p>
<p>Schreib am besten eine Klasse Node und eine Klasse LinkedList.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1048186</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1048186</guid><dc:creator><![CDATA[Fachmann für Listen]]></dc:creator><pubDate>Sun, 30 Apr 2006 09:56:41 GMT</pubDate></item><item><title><![CDATA[Reply to Linked List on Mon, 01 May 2006 00:15:12 GMT]]></title><description><![CDATA[<p>So siehts zur Zeit aus... zur Zeit liegt OO-Programmierung noch ausserhalb meiner Möglichkeiten, wesshalb ich das mit den Klassen wahrscheinlich auch gar ned umsetzen könnte.</p>
<pre><code class="language-cpp">#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;

#define WIN32_LEAN_AND_MEAN

typedef unsigned int uint;

typedef struct NODE_TYP 
{
  uint id_no;
  char name[32];
  uint age;
  struct NODE_TYP *next;
  struct NODE_TYP *prev;
}NODE, *NODE_PTR;

void traverseList(NODE_PTR head);
NODE_PTR insertNode(NODE_PTR *head, NODE_PTR *tail, uint id_num,uint age,char *name);
int deleteNode(NODE_PTR *head, NODE_PTR *tail, uint id_num);

int main(int argc, char argv[])
{
  //need a head and a tail for every list.
  //atm. List is empty so point to NULL
  NODE_PTR l_head=NULL;
  NODE_PTR l_tail=NULL;

  insertNode(&amp;l_head,&amp;l_tail,1,28,&quot;michi&quot;);
  insertNode(&amp;l_head,&amp;l_tail,2,29,&quot;muchu&quot;);
  traverseList(l_head);

  return 0;
}

void traverseList(NODE_PTR head)
{
  //this function traverses the list and prints out
  //each node.

  //test if head is NULL
  if (head==NULL)
  {
    printf(&quot;\nLinked List is empty\n&quot;);
    return;
  }//end if

  //traverse list while nodes
  while (head==NULL)
  {
    //visit the node, print out,go to next node
    printf(&quot;\nNode-Data:\n&quot;);
    printf(&quot;id...: %d\n&quot;, head-&gt;id_no);
    printf(&quot;name.: %s\n&quot;, head-&gt;name);
    printf(&quot;age..: %d\n&quot;, head-&gt;age);
    //advance to next node
    head = head-&gt;next;
  }//end while
  printf(&quot;\n&quot;);
}//end traverseList

NODE_PTR insertNode(NODE_PTR *head, NODE_PTR *tail, uint id_num,uint age,char *name)
{
  //this function inserts a node at the end of the list
  NODE_PTR newNode =NULL;

  //Step1, create new node
  newNode =(NODE_PTR)malloc(sizeof(NODE));
  //fill in data
  newNode-&gt;id_no  =id_num;
  newNode-&gt;age    =age;
  strcpy_s(newNode-&gt;name,name);
  newNode-&gt;next   =NULL;

  //Step2, check stat of list
  if (head==NULL)
  {
    //empty List, simplest case
    *head=newNode;
    *tail=newNode;
    //return new node
    return(newNode);
  }
  else
  {
    if (*head != NULL &amp;&amp; *head == *tail)
    {
      //there is exactly one node in the list
      *head-&gt;next =newNode;                    //&lt;- hier tritt der Fehler auf
      *tail =newNode;
      //return new node
      return(newNode);
    }
    else
    {
      //there are 2 or more nodes in the list
      //put new node at the end of the list
      *tail-&gt;next =newNode;
      *tail =newNode;
      //return new node
      return(newNode);
    }
  }
}//end insertNode

int deleteNode(NODE_PTR *head, NODE_PTR *tail, uint id_num)
{
  //this function deletes a node from the list
  //argument is id_no
  NODE_PTR currPtr =*head;
  NODE_PTR prevPtr =*head;

  //test if there is a l.list to delete from
  if(!head)
    return(-1);

  //traverse the list and find node to delete
  while (currPtr-&gt;id_no != id_num)
  {
    //save this position
    prevPtr =currPtr;
    currPtr =currPtr-&gt;next;
  }

  //at this point we have found the node
  //or the end of the list
  if (currPtr == NULL)
    return(-1);//EndOfList

  //Record was found, delete it, but be carefull
  //need to test cases

  //Case1, one element
  if (head==tail)
  {
    free(head);    //delete node
    head=tail=NULL;//fix pointers

    printf(&quot;Case1.record%d found and deleted&quot;,id_num);
    return(id_num);
  }
  else //Case2, front of list
    if (currPtr==*head)
    {
      //move head to next node
      *head=*head-&gt;next;
      //delete the node
      free(currPtr);
      printf(&quot;Case2.record%d found and deleted&quot;,id_num);
      return(id_num);
    }
    else //Case3, end of list
      if (currPtr==*tail)
      {
        //fix prev. pointer to point to NULL
        prevPtr-&gt;next;
        //delete last node
        free(currPtr);
        //point tail to prev. node
        *tail=prevPtr;
        printf(&quot;Case3.record%d found and deleted&quot;,id_num);
        return(id_num);
      }
      else //Case4, node is in the middle of the list
      {
        //connect prev. node to next node
        prevPtr-&gt;next =currPtr-&gt;next;
        //delete current node
        free(currPtr);
        printf(&quot;Case4.record%d found and deleted&quot;,id_num);
        return(id_num);
      }
}//end deleteNode
</code></pre>
<p>Wie gesagt ich habe alle Spielarten mit *,. und -&gt; ausprobiert. Aber irgend etwas hab ich anscheinend vergessen oder nicht kapiert...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1048680</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1048680</guid><dc:creator><![CDATA[noobiex]]></dc:creator><pubDate>Mon, 01 May 2006 00:15:12 GMT</pubDate></item><item><title><![CDATA[Reply to Linked List on Mon, 01 May 2006 10:57:37 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">(*head)-&gt;next =newNode;                    //&lt;- hier tritt der Fehler nicht mehr auf
</code></pre>
<p>Kurt</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1048821</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1048821</guid><dc:creator><![CDATA[ZuK]]></dc:creator><pubDate>Mon, 01 May 2006 10:57:37 GMT</pubDate></item><item><title><![CDATA[Reply to Linked List on Tue, 02 May 2006 10:51:45 GMT]]></title><description><![CDATA[<p>Danke, genau das wars! Auf Klammern wäre ich nie gekommen. Das sieht so...falsch aus. *head steht ja nicht für eine komplette Rechnung. Oder etwa doch?<br />
Naja, ich werde es erstmal in die Kategorie &quot;Kurioses&quot; speichern und in Zukunft head und tail als Globals definieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1049448</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1049448</guid><dc:creator><![CDATA[noobiex]]></dc:creator><pubDate>Tue, 02 May 2006 10:51:45 GMT</pubDate></item></channel></rss>