<?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[Struct]]></title><description><![CDATA[<p>Hallo,</p>
<p>bin relativ neu in C/C++ und versuche gerade ein kleines Programm (Tabelle für Fifa 11:) zu schreiben, in der ich eine struct brauch in der eine weitere struct ist.</p>
<p>Dafür habe ich zunächst eine struct, die die Daten eines jeden Spielers erfassen soll, sieht wie folgt aus:</p>
<p>struct spieler{</p>
<p>char name[15];<br />
short tore;<br />
short vorlagen;<br />
};</p>
<p>Jetzt habe ich eine weitere struct angelegt, die die Daten einer jeden Mannschaft erfassen soll, sieht wie folgt aus:</p>
<p>struct mannschaft{</p>
<p><strong>struct spieler s_feld[15];</strong><br />
short tore;<br />
short gegentore;<br />
short punkte;<br />
short siege;<br />
short unentschieden;<br />
short niederlagen;</p>
<p>}a,b,c,d,e;</p>
<p>Bin ich richtig der Annahme, dass durch <strong>sruct spieler s_feld[15]</strong><br />
15 Variablen vom Typ struct spieler pro struct mannschaft angelegt werden?</p>
<p>Wenn ich nun bspw. den ersten Spielernamen von Mannschaft a bearbeiten möchte,<br />
müsste das mit<br />
cin &gt;&gt; name.s_feld[0].a;<br />
klappen, oder nicht?</p>
<p>Ich brings leider nicht zum Laufen und seh meinen Fehler nicht. Freue mich über jede Hilfe. Danke schonmal im vorraus.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/288520/struct</link><generator>RSS for Node</generator><lastBuildDate>Wed, 19 Aug 2026 23:15:03 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/288520.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 18 Jun 2011 11:51:27 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Struct on Sat, 18 Jun 2011 11:51:27 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>bin relativ neu in C/C++ und versuche gerade ein kleines Programm (Tabelle für Fifa 11:) zu schreiben, in der ich eine struct brauch in der eine weitere struct ist.</p>
<p>Dafür habe ich zunächst eine struct, die die Daten eines jeden Spielers erfassen soll, sieht wie folgt aus:</p>
<p>struct spieler{</p>
<p>char name[15];<br />
short tore;<br />
short vorlagen;<br />
};</p>
<p>Jetzt habe ich eine weitere struct angelegt, die die Daten einer jeden Mannschaft erfassen soll, sieht wie folgt aus:</p>
<p>struct mannschaft{</p>
<p><strong>struct spieler s_feld[15];</strong><br />
short tore;<br />
short gegentore;<br />
short punkte;<br />
short siege;<br />
short unentschieden;<br />
short niederlagen;</p>
<p>}a,b,c,d,e;</p>
<p>Bin ich richtig der Annahme, dass durch <strong>sruct spieler s_feld[15]</strong><br />
15 Variablen vom Typ struct spieler pro struct mannschaft angelegt werden?</p>
<p>Wenn ich nun bspw. den ersten Spielernamen von Mannschaft a bearbeiten möchte,<br />
müsste das mit<br />
cin &gt;&gt; name.s_feld[0].a;<br />
klappen, oder nicht?</p>
<p>Ich brings leider nicht zum Laufen und seh meinen Fehler nicht. Freue mich über jede Hilfe. Danke schonmal im vorraus.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2080096</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2080096</guid><dc:creator><![CDATA[josefh]]></dc:creator><pubDate>Sat, 18 Jun 2011 11:51:27 GMT</pubDate></item><item><title><![CDATA[Reply to Struct on Sat, 18 Jun 2011 11:54:58 GMT]]></title><description><![CDATA[<blockquote>
<p>cin &gt;&gt; name.s_feld[0].a;</p>
</blockquote>
<p>Umgekehrt: <code>a.s_feld[0].name</code></p>
<blockquote>
<p>bin relativ neu in C/C++</p>
</blockquote>
<p>Und du hast tatsächlich C/C++ gelernt hast, was nicht gut für dich ist, weil du nun sowohl C als auch C++ nicht richtig kannst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2080099</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2080099</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Sat, 18 Jun 2011 11:54:58 GMT</pubDate></item><item><title><![CDATA[Reply to Struct on Sat, 18 Jun 2011 11:57:37 GMT]]></title><description><![CDATA[<p>Wohl eher mit</p>
<pre><code class="language-cpp">mannschaft schalke;
cin &gt;&gt; schalke.s_feld[0].name;
</code></pre>
<p>Aber warum nutzt du kein std::string/std::vector?</p>
<p>Edit:<br />
Der war schon wieder schneller, verdammt! <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/2080100</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2080100</guid><dc:creator><![CDATA[cooky451]]></dc:creator><pubDate>Sat, 18 Jun 2011 11:57:37 GMT</pubDate></item><item><title><![CDATA[Reply to Struct on Sat, 18 Jun 2011 12:07:45 GMT]]></title><description><![CDATA[<p>wenn du das hier hast:</p>
<pre><code class="language-cpp">struct foo
{
    int a;
    int b;
};
</code></pre>
<p>erzeust du eine variable so:</p>
<pre><code class="language-cpp">foo beispiel; // ohne struct
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2080104</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2080104</guid><dc:creator><![CDATA[Skym0sh0]]></dc:creator><pubDate>Sat, 18 Jun 2011 12:07:45 GMT</pubDate></item><item><title><![CDATA[Reply to Struct on Sat, 18 Jun 2011 12:12:21 GMT]]></title><description><![CDATA[<p>SeppJ schrieb:</p>
<blockquote>
<p>Und du hast tatsächlich C/C++ gelernt hast, was nicht gut für dich ist, weil du nun sowohl C als auch C++ nicht richtig kannst.</p>
</blockquote>
<p>Ich lern's auch noch nicht richtig, gehe noch zur Schule und bedien mich bisher nur an alten Skripten von meinem Bruder und einem, meiner Ansicht nach schlechtem Buch.</p>
<p>Danke für die Hilfe, bisschen peinlich, dass mir nicht die falsche Reihenfolge aufgefallen ist:D</p>
<p>std::string bzw vector kannte ich noch nicht, gerade bisschen was drüber gelesen, scheint die Sache sehr zu vereinfachen.</p>
<p>Wie würde es dann aber konkret aussehen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2080105</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2080105</guid><dc:creator><![CDATA[josefh]]></dc:creator><pubDate>Sat, 18 Jun 2011 12:12:21 GMT</pubDate></item><item><title><![CDATA[Reply to Struct on Sat, 18 Jun 2011 12:15:49 GMT]]></title><description><![CDATA[<p>Statt</p>
<pre><code class="language-cpp">struct spieler{ 

char name[15]; 
short tore; 
short vorlagen; 
}; 
struct mannschaft{ 

struct spieler s_feld[15]; 
short tore; 
short gegentore; 
short punkte; 
short siege; 
short unentschieden; 
short niederlagen; 

}a,b,c,d,e;
</code></pre>
<p>einfach</p>
<pre><code class="language-cpp">struct spieler{ 
std::string Name;          //Kein Char-Array mehr
short tore; 
short vorlagen; 
}; 
struct mannschaft{ 
std::vecor&lt;spieler&gt; leute; //Oder std::array wenn du einen C++0x-Fähigen Compiler hast
short tore; 
short gegentore; 
short punkte; 
short siege; 
short unentschieden; 
short niederlagen; 
}a,b,c,d,e;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2080108</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2080108</guid><dc:creator><![CDATA[EOutOfResources]]></dc:creator><pubDate>Sat, 18 Jun 2011 12:15:49 GMT</pubDate></item><item><title><![CDATA[Reply to Struct on Sat, 18 Jun 2011 12:19:09 GMT]]></title><description><![CDATA[<p>Vielen Dank!<br />
Wie könnte ich jetzt durch die verschiedenen &quot;leute&quot; durchiterieren?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2080110</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2080110</guid><dc:creator><![CDATA[josefh]]></dc:creator><pubDate>Sat, 18 Jun 2011 12:19:09 GMT</pubDate></item><item><title><![CDATA[Reply to Struct on Sat, 18 Jun 2011 12:40:20 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/26914">@josefh</a><br />
Genau so, wie du durch jedes Array oder vector durchiterierst.</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/25179">@EOutOfResources</a><br />
std::vector ist schon gut. Bei std::array müsstest du eine feste Grösse angeben (ist ja nur ein Wrapper für native Arrays).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2080117</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2080117</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Sat, 18 Jun 2011 12:40:20 GMT</pubDate></item><item><title><![CDATA[Reply to Struct on Sat, 18 Jun 2011 16:57:31 GMT]]></title><description><![CDATA[<p>drakon schrieb:</p>
<blockquote>
<p>std::vector ist schon gut.</p>
</blockquote>
<p>Wenn es ja eh immer nur 15 Spieler sind, finde ich <code>std::array</code> besser.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2080255</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2080255</guid><dc:creator><![CDATA[EOutOfResources]]></dc:creator><pubDate>Sat, 18 Jun 2011 16:57:31 GMT</pubDate></item><item><title><![CDATA[Reply to Struct on Sat, 18 Jun 2011 17:31:57 GMT]]></title><description><![CDATA[<p>EOutOfResources schrieb:</p>
<blockquote>
<p>drakon schrieb:</p>
<blockquote>
<p>std::vector ist schon gut.</p>
</blockquote>
<p>Wenn es ja eh immer nur 15 Spieler sind, finde ich <code>std::array</code> besser.</p>
</blockquote>
<p>Das ist imo eine unnötige Einschränkung. Eine Mannschaft hat nicht immer exakt 15 Spieler und sollte daher sollte die Struktur das auch so repräsentieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2080270</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2080270</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Sat, 18 Jun 2011 17:31:57 GMT</pubDate></item><item><title><![CDATA[Reply to Struct on Sat, 18 Jun 2011 17:33:07 GMT]]></title><description><![CDATA[<p>drakon schrieb:</p>
<blockquote>
<p>Eine Mannschaft hat nicht immer exakt 15 Spieler</p>
</blockquote>
<p>Sieh seinen Code an!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2080271</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2080271</guid><dc:creator><![CDATA[EOutOfResources]]></dc:creator><pubDate>Sat, 18 Jun 2011 17:33:07 GMT</pubDate></item><item><title><![CDATA[Reply to Struct on Sat, 18 Jun 2011 18:29:51 GMT]]></title><description><![CDATA[<p>EOutOfResources schrieb:</p>
<blockquote>
<p>drakon schrieb:</p>
<blockquote>
<p>Eine Mannschaft hat nicht immer exakt 15 Spieler</p>
</blockquote>
<p>Sieh seinen Code an!</p>
</blockquote>
<p><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="🙄"
    /><br />
Nur weil er das mal in seinem Code so hat macht es das gut? Er hat auch eine Einschränkung, dass Spieler lediglich einen Namen haben dürfen, der 14 Zeichen lang ist, was auch keine gute Idee ist das so statisch zu machen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2080295</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2080295</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Sat, 18 Jun 2011 18:29:51 GMT</pubDate></item></channel></rss>