<?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[verkettete Listen]]></title><description><![CDATA[<p>hi leute ich hab hier ein problem.<br />
Also ich will, dass im Unterprogramm Neues_Element eben ein Neues Element in der Liste hinzugefügt wird, das problem ist aber dass bei der Ausgabe jetzt nicht Sepp ausgegeben wird sonder die Adresse des Pointers pc. Ich weis einfach nicht was ich da machen soll kann mird jemand helfen?</p>
<p>#include &lt;iostream&gt;<br />
#include &lt;stdio.h&gt;<br />
#include &lt;string&gt;<br />
#include &lt;iomanip&gt;</p>
<p>using namespace std;</p>
<p>struct ListElm {int Prio; string *name; struct ListElm *next;};</p>
<p>void PrintElm(struct ListElm *z)<br />
{<br />
cout &lt;&lt; &quot;\nListenelement:&quot;<br />
&lt;&lt; &quot;\nGroese in Byte: &quot; &lt;&lt; dec &lt;&lt; sizeof (*z)<br />
&lt;&lt; &quot;\nPrioritaet: &quot; &lt;&lt; z-&gt;Prio<br />
&lt;&lt; &quot;\nName: &quot; &lt;&lt; z-&gt;name<br />
&lt;&lt; &quot;\nVerkettungsinfo: &quot; &lt;&lt; hex &lt;&lt; z-&gt;next<br />
&lt;&lt; dec &lt;&lt; &quot;\n\n&quot;;<br />
}</p>
<p>void PrintList(struct ListElm *Tail)<br />
{<br />
while (Tail != NULL)<br />
{<br />
cout &lt;&lt; &quot;\nListenelement:&quot;<br />
&lt;&lt; &quot;\nGroese in Byte: &quot; &lt;&lt; dec &lt;&lt; sizeof (*Tail)<br />
&lt;&lt; &quot;\nPrioritaet: &quot; &lt;&lt; Tail-&gt;Prio<br />
&lt;&lt; &quot;\nName: &quot; &lt;&lt; Tail-&gt;name<br />
&lt;&lt; &quot;\nVerkettungsinfo: &quot; &lt;&lt; hex &lt;&lt; Tail-&gt;next<br />
&lt;&lt; dec &lt;&lt;&quot;\n\n&quot;;<br />
Tail = Tail-&gt;next;<br />
}</p>
<p>}</p>
<p>struct ListElm* Neues_Element(int prio, const string s, struct ListElm *naechste)<br />
{<br />
struct ListElm *a;<br />
string *pc;<br />
string c;</p>
<p>a = new struct ListElm;<br />
a-&gt;Prio = prio;</p>
<p>pc = new string;<br />
*pc = s;<br />
a-&gt;name = pc;</p>
<p>a-&gt;next = naechste;</p>
<p>return a;</p>
<p>}</p>
<p>//_____________________________________________________________________________________________________________________________</p>
<p>int main()<br />
{<br />
struct ListElm *Wurzel, *element1;<br />
char bez1 [] = &quot;Sepp&quot;;</p>
<p>element1 = Neues_Element(1, &quot;Sepp&quot;, NULL);<br />
Wurzel = element1;</p>
<p>PrintList(Wurzel);</p>
<p>system(&quot;PAUSE&quot;);<br />
return 0;<br />
}</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/205218/verkettete-listen</link><generator>RSS for Node</generator><lastBuildDate>Fri, 09 Oct 2026 00:32:08 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/205218.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 11 Feb 2008 20:03:48 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to verkettete Listen on Mon, 11 Feb 2008 20:03:48 GMT]]></title><description><![CDATA[<p>hi leute ich hab hier ein problem.<br />
Also ich will, dass im Unterprogramm Neues_Element eben ein Neues Element in der Liste hinzugefügt wird, das problem ist aber dass bei der Ausgabe jetzt nicht Sepp ausgegeben wird sonder die Adresse des Pointers pc. Ich weis einfach nicht was ich da machen soll kann mird jemand helfen?</p>
<p>#include &lt;iostream&gt;<br />
#include &lt;stdio.h&gt;<br />
#include &lt;string&gt;<br />
#include &lt;iomanip&gt;</p>
<p>using namespace std;</p>
<p>struct ListElm {int Prio; string *name; struct ListElm *next;};</p>
<p>void PrintElm(struct ListElm *z)<br />
{<br />
cout &lt;&lt; &quot;\nListenelement:&quot;<br />
&lt;&lt; &quot;\nGroese in Byte: &quot; &lt;&lt; dec &lt;&lt; sizeof (*z)<br />
&lt;&lt; &quot;\nPrioritaet: &quot; &lt;&lt; z-&gt;Prio<br />
&lt;&lt; &quot;\nName: &quot; &lt;&lt; z-&gt;name<br />
&lt;&lt; &quot;\nVerkettungsinfo: &quot; &lt;&lt; hex &lt;&lt; z-&gt;next<br />
&lt;&lt; dec &lt;&lt; &quot;\n\n&quot;;<br />
}</p>
<p>void PrintList(struct ListElm *Tail)<br />
{<br />
while (Tail != NULL)<br />
{<br />
cout &lt;&lt; &quot;\nListenelement:&quot;<br />
&lt;&lt; &quot;\nGroese in Byte: &quot; &lt;&lt; dec &lt;&lt; sizeof (*Tail)<br />
&lt;&lt; &quot;\nPrioritaet: &quot; &lt;&lt; Tail-&gt;Prio<br />
&lt;&lt; &quot;\nName: &quot; &lt;&lt; Tail-&gt;name<br />
&lt;&lt; &quot;\nVerkettungsinfo: &quot; &lt;&lt; hex &lt;&lt; Tail-&gt;next<br />
&lt;&lt; dec &lt;&lt;&quot;\n\n&quot;;<br />
Tail = Tail-&gt;next;<br />
}</p>
<p>}</p>
<p>struct ListElm* Neues_Element(int prio, const string s, struct ListElm *naechste)<br />
{<br />
struct ListElm *a;<br />
string *pc;<br />
string c;</p>
<p>a = new struct ListElm;<br />
a-&gt;Prio = prio;</p>
<p>pc = new string;<br />
*pc = s;<br />
a-&gt;name = pc;</p>
<p>a-&gt;next = naechste;</p>
<p>return a;</p>
<p>}</p>
<p>//_____________________________________________________________________________________________________________________________</p>
<p>int main()<br />
{<br />
struct ListElm *Wurzel, *element1;<br />
char bez1 [] = &quot;Sepp&quot;;</p>
<p>element1 = Neues_Element(1, &quot;Sepp&quot;, NULL);<br />
Wurzel = element1;</p>
<p>PrintList(Wurzel);</p>
<p>system(&quot;PAUSE&quot;);<br />
return 0;<br />
}</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1453954</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1453954</guid><dc:creator><![CDATA[Flo8989]]></dc:creator><pubDate>Mon, 11 Feb 2008 20:03:48 GMT</pubDate></item><item><title><![CDATA[Reply to verkettete Listen on Mon, 11 Feb 2008 20:20:33 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;stdio.h&gt;
#include &lt;string&gt;
#include &lt;iomanip&gt;

using namespace std;

struct ListElm {int Prio; string *name; struct ListElm *next;};

void PrintElm(struct ListElm *z)
{
cout &lt;&lt; &quot;\nListenelement:&quot;
&lt;&lt; &quot;\nGroese in Byte: &quot; &lt;&lt; dec &lt;&lt; sizeof (*z)
&lt;&lt; &quot;\nPrioritaet: &quot; &lt;&lt; z-&gt;Prio
&lt;&lt; &quot;\nName: &quot; &lt;&lt; z-&gt;name
&lt;&lt; &quot;\nVerkettungsinfo: &quot; &lt;&lt; hex &lt;&lt; z-&gt;next
&lt;&lt; dec &lt;&lt; &quot;\n\n&quot;;
}

void PrintList(struct ListElm *Tail)
{
while (Tail != NULL)
{
cout &lt;&lt; &quot;\nListenelement:&quot;
&lt;&lt; &quot;\nGroese in Byte: &quot; &lt;&lt; dec &lt;&lt; sizeof (*Tail)
&lt;&lt; &quot;\nPrioritaet: &quot; &lt;&lt; Tail-&gt;Prio
&lt;&lt; &quot;\nName: &quot; &lt;&lt; Tail-&gt;name
&lt;&lt; &quot;\nVerkettungsinfo: &quot; &lt;&lt; hex &lt;&lt; Tail-&gt;next
&lt;&lt; dec &lt;&lt;&quot;\n\n&quot;;
Tail = Tail-&gt;next;
}

}

struct ListElm* Neues_Element(int prio, const string s, struct ListElm *naechste)
{
struct ListElm *a;
string *pc;
string c;

a = new struct ListElm;
a-&gt;Prio = prio;

pc = new string;
*pc = s;
a-&gt;name = pc;

a-&gt;next = naechste;

return a;

}
</code></pre>
<pre><code class="language-cpp">int main()
{
struct ListElm *Wurzel, *element1;
char bez1 [] = &quot;Sepp&quot;;

element1 = Neues_Element(1, &quot;Sepp&quot;, NULL);
Wurzel = element1;

PrintList(Wurzel);

system(&quot;PAUSE&quot;);
return 0;
}
</code></pre>
<p>Code-Tags ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1453968</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1453968</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Mon, 11 Feb 2008 20:20:33 GMT</pubDate></item><item><title><![CDATA[Reply to verkettete Listen on Mon, 11 Feb 2008 20:35:18 GMT]]></title><description><![CDATA[<p>Und mit c++ hat das nichts zu tun <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="😉"
    /></p>
<p>Naja wenn du schon keine Klasse nutzen willst ... was schwachsin ist:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;iomanip&gt;

struct list_element
{
	int priority; 
	std::string data; 
	list_element* ptr_next;

	list_element(int priority, std::string const&amp; data, list_element* ptr_next(NULL))
		: priority(priority), data(data), ptr_next(ptr_next)
	{}
};

void print_element(list_element const&amp; element)
{
	std::cout	&lt;&lt; &quot;\nListenelement: &quot;
				&lt;&lt; &quot;\n-Groesse in Byte: &quot; &lt;&lt; std::dec &lt;&lt; sizeof (element)
				&lt;&lt; &quot;\n-Prioritaet: &quot; &lt;&lt; element.priority
				&lt;&lt; &quot;\n-Daten: &quot; &lt;&lt; element.data
				&lt;&lt; &quot;\nVerkettungsinfo: &quot; &lt;&lt; std::hex &lt;&lt; element.ptr_next &lt;&lt; std::endl;
}

void print_list(list_element const&amp; first)
{
	for (const list_element* ptr(&amp;first); ptr; ptr = ptr-&gt;ptr_next)
		print_element(*ptr);
}

list_element* create_element(int priority, std::string const&amp; data, list_element* next)
{ return new list_element(priority, data, next); }

void delete_element(list_element*&amp; ptr_element)
{ delete ptr_element; ptr_element = NULL; }

int main()
{
	list_element* root(create_element(1, &quot;Sepp&quot;, create_element(1, &quot;Depp&quot;, NULL)));
	print_list(*root);
	std::cin.get();
}
</code></pre>
<p>Aber jetzt wird dir auch auffallen, warum dein Konzept so nicht so sinnvoll ist. Du bräuchtest eine Methode insert_element ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1453972</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1453972</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Mon, 11 Feb 2008 20:35:18 GMT</pubDate></item><item><title><![CDATA[Reply to verkettete Listen on Mon, 11 Feb 2008 21:13:55 GMT]]></title><description><![CDATA[<p>ich weis auch, dass man dass besser mit klassen machen sollte aber es ist ein praktikumsaufgabe für mein mechatronikstudium und klassen lernt man erst im nächsten kapitel. es is halt so eine art &quot;einführungsaufgabe&quot;</p>
<p>also verstehen tu ich es noch nicht. ich habs mal kopiert und ausprobiert aber bei mir kommt dann beim compilieren schon mal ne fehlermeldung.<br />
außerdem benutzt du keinen pointer in struct ( ich hab ein pointer auf string und du nimmst nur einen string)</p>
<p>es steht leider in der angabe, dass man ein pointer nehmen soll eigentlich ein pointer auf char. wie gesagt mein problem is , dass wenn du meinen code compilierst nicht sepp ausgegeben wird sondern die adresse des pointers pc!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1454007</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1454007</guid><dc:creator><![CDATA[Flo8989]]></dc:creator><pubDate>Mon, 11 Feb 2008 21:13:55 GMT</pubDate></item><item><title><![CDATA[Reply to verkettete Listen on Mon, 11 Feb 2008 21:27:08 GMT]]></title><description><![CDATA[<p>Flo8989 schrieb:</p>
<blockquote>
<p>wie gesagt mein problem is , dass wenn du meinen code compilierst nicht sepp ausgegeben wird sondern die adresse des pointers pc!</p>
</blockquote>
<p>Dann dereferenzier' ihn!</p>
<p>greetz, Swordfish</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1454017</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1454017</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Mon, 11 Feb 2008 21:27:08 GMT</pubDate></item><item><title><![CDATA[Reply to verkettete Listen on Tue, 12 Feb 2008 08:37:58 GMT]]></title><description><![CDATA[<p>ah jetzt hab ichs schon gelöst danke für die antworten</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1454152</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1454152</guid><dc:creator><![CDATA[Flo8989]]></dc:creator><pubDate>Tue, 12 Feb 2008 08:37:58 GMT</pubDate></item></channel></rss>