<?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[Dynamische Strukturen Array]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich brauch mal eure Hilfe im Punkto &quot;Dynamische Strukturen Array&quot;<br />
in C++. Wie ich das ganze mit &quot;calloc&quot; und free machen weiß ich.<br />
Ich wollte jedoch mal nachfragen ob es nicht eine andere Lösung gibt<br />
die rein C**++** ist?</p>
<p>gruß<br />
zyon</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/160483/dynamische-strukturen-array</link><generator>RSS for Node</generator><lastBuildDate>Sat, 12 Sep 2026 03:15:03 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/160483.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 26 Sep 2006 10:36:08 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Dynamische Strukturen Array on Tue, 26 Sep 2006 10:36:08 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich brauch mal eure Hilfe im Punkto &quot;Dynamische Strukturen Array&quot;<br />
in C++. Wie ich das ganze mit &quot;calloc&quot; und free machen weiß ich.<br />
Ich wollte jedoch mal nachfragen ob es nicht eine andere Lösung gibt<br />
die rein C**++** ist?</p>
<p>gruß<br />
zyon</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1144600</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1144600</guid><dc:creator><![CDATA[zyon]]></dc:creator><pubDate>Tue, 26 Sep 2006 10:36:08 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamische Strukturen Array on Tue, 26 Sep 2006 10:37:58 GMT]]></title><description><![CDATA[<p>Was verstehst du unter &quot;Dynamische Strukturen Array&quot;? Gib doch mal dein C Beispiel an.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1144601</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1144601</guid><dc:creator><![CDATA[Chris++ 0]]></dc:creator><pubDate>Tue, 26 Sep 2006 10:37:58 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamische Strukturen Array on Tue, 26 Sep 2006 10:46:06 GMT]]></title><description><![CDATA[<p>Ja, in C++ könntest du new[] und delete[] verwenden anstelle von calloc() und free(). Oder du verwendest die vorhandenen Containerklassen (vector&lt;&gt; etc).</p>
<p>PS: Schau dich doch mal ganz weit unten im Magazin um, da findest du sowohl zur Speicherverwaltung als auch zu den STL-Containern einige Informationen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1144609</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1144609</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Tue, 26 Sep 2006 10:46:06 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamische Strukturen Array on Tue, 26 Sep 2006 10:50:47 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">struct TVokabelListe {
    int id;
    string deutsch;
    string english;
   };

   struct TVokabelListe *myVokabel;

   myVokabel = (struct TVokabelListe *)calloc(100, sizeof(struct TVokabelListe));
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1144614</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1144614</guid><dc:creator><![CDATA[zyon]]></dc:creator><pubDate>Tue, 26 Sep 2006 10:50:47 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamische Strukturen Array on Tue, 26 Sep 2006 10:57:41 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">myVokabel = new TVokabelListe[100];
</code></pre>
<p>btw ist &quot;TVokabel<em>Liste</em>&quot; ein etwas ungünstiger Name für eine einzelne Vokabel <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>
]]></description><link>https://www.c-plusplus.net/forum/post/1144617</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1144617</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Tue, 26 Sep 2006 10:57:41 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamische Strukturen Array on Tue, 26 Sep 2006 11:18:28 GMT]]></title><description><![CDATA[<p>Ich würd Dir wirklich eine map empfehlen, erspart ne Menge Arbeit, und wieso immer das Rad neu erfinden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1144634</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1144634</guid><dc:creator><![CDATA[THX 1138]]></dc:creator><pubDate>Tue, 26 Sep 2006 11:18:28 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamische Strukturen Array on Tue, 26 Sep 2006 22:01:40 GMT]]></title><description><![CDATA[<p>Aber nicht das delete[] vergessen.<br />
In diesem Fall</p>
<pre><code class="language-cpp">delete[] TVokabelListe;
</code></pre>
<p>delete ohne &quot;[]&quot; ist dabei ganz böse.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1145164</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1145164</guid><dc:creator><![CDATA[Caribbean Blue]]></dc:creator><pubDate>Tue, 26 Sep 2006 22:01:40 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamische Strukturen Array on Wed, 27 Sep 2006 05:33:04 GMT]]></title><description><![CDATA[<p>Caribbean Blue schrieb:</p>
<blockquote>
<p>Aber nicht das delete[] vergessen.<br />
In diesem Fall</p>
<pre><code class="language-cpp">delete[] TVokabelListe;
</code></pre>
<p>delete ohne &quot;[]&quot; ist dabei ganz böse.</p>
</blockquote>
<p>delete [] mit TVokabelListe ist auch ganz böse. Lieber:</p>
<pre><code class="language-cpp">delete [] myVokabel;
</code></pre>
<p>grüße</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1145204</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1145204</guid><dc:creator><![CDATA[David_pb]]></dc:creator><pubDate>Wed, 27 Sep 2006 05:33:04 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamische Strukturen Array on Mon, 16 Oct 2006 09:42:42 GMT]]></title><description><![CDATA[<p>THX 1138 schrieb:</p>
<blockquote>
<p>Ich würd Dir wirklich eine map empfehlen, erspart ne Menge Arbeit, und wieso immer das Rad neu erfinden.</p>
</blockquote>
<p>jetzt wollte ich mich an maps wagen aber scheitere schon am inster:</p>
<pre><code class="language-cpp">map&lt;int, string, string&gt; myVokabelMap;

   while ( ! myFile.eof() ) {
       getline(myFile, sLine);
       string::size_type pos = sLine.find(&quot;:&quot;);
       ++i;
       myVokabelMap.insert( i, sLine.substr(0,pos-1), sLine.substr(pos+1,sLine.length()) );
   }
</code></pre>
<p>was mache ich den da so falsch</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1155538</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1155538</guid><dc:creator><![CDATA[zyon]]></dc:creator><pubDate>Mon, 16 Oct 2006 09:42:42 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamische Strukturen Array on Mon, 16 Oct 2006 09:54:49 GMT]]></title><description><![CDATA[<p>Eine map&lt;&gt; verwendet nur zwei Template-Parameter (OK, eigentlich vier - aber die letzten Parameter sind die Vergleichsfunktion und der Allokator), also dürfte schon dein &quot;map&lt;int,string,string&gt;&quot; nicht funktionieren. Zur Lösung könntest du den ID-Teil weglassen:</p>
<pre><code class="language-cpp">map&lt;string, string&gt; myVokabelMap;

while ( ! myFile.eof() ) {
  getline(myFile, sLine);
  string::size_type pos = sLine.find(&quot;:&quot;);
  myVokabelMap.insert( std::make_pair(sLine.substr(0,pos-1), sLine.substr(pos+1,sLine.length())) );
}
</code></pre>
<p>(btw, wenn der selbe Begriff mehrfach in deiner Vokalliste vorkommen kann - nimm besser eine multimap&lt;&gt;)</p>
<p>PS: &quot;klappt nicht&quot; ist nur in wenigen Fällen hilfreich - meistens bringt es etwas, die Fehlermeldungen des Compilers mitzuliefern.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1155558</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1155558</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 16 Oct 2006 09:54:49 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamische Strukturen Array on Mon, 16 Oct 2006 12:29:26 GMT]]></title><description><![CDATA[<blockquote>
<pre><code class="language-cpp">while ( ! myFile.eof() )
</code></pre>
</blockquote>
<p>Puhuuh. Gefääährlich. Pöse. Was is mit bad-bit und fail-bit? Besser:</p>
<pre><code class="language-cpp">while(myFile.good())
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1155680</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1155680</guid><dc:creator><![CDATA[Plotzenhotz]]></dc:creator><pubDate>Mon, 16 Oct 2006 12:29:26 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamische Strukturen Array on Mon, 16 Oct 2006 14:18:04 GMT]]></title><description><![CDATA[<p>Danke CStoll und Plotzenhotz</p>
<p>Was ich nicht versteh ist das hier. Ich fülle meine mal mir ca. 80 einträgen und<br />
wenn ich dann ein &quot;test = myVokabelMap.size();&quot; mache steht da nur 2 drin!? Wieso?</p>
<pre><code class="language-cpp">typedef map&lt;string, string&gt; Vokabelen;

   Vokabelen myVokabelMap;

   while ( ! myFile.eof() ) {
       getline(myFile, sLine);
       string::size_type pos = sLine.find(&quot;:&quot;);
       myVokabelMap.insert( make_pair(sLine.substr(0,pos-1), sLine.substr(pos+1,sLine.length())) );
   }
   int test;
   test = myVokabelMap.size();
</code></pre>
<p>gruß und dank</p>
<p>zyon</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1155768</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1155768</guid><dc:creator><![CDATA[zyon]]></dc:creator><pubDate>Mon, 16 Oct 2006 14:18:04 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamische Strukturen Array on Tue, 17 Oct 2006 00:30:14 GMT]]></title><description><![CDATA[<p>Füge vor dem myVokabelMap.insert(...) folgendes ein:</p>
<pre><code class="language-cpp">std::cout &lt;&lt; &quot;[&quot; &lt;&lt; sLine.substr(0,pos-1) &lt;&lt; &quot;]&quot; &lt;&lt; std::endl &lt;&lt; std::flush;
</code></pre>
<p>Dann siehst du welche Keys du verwendest - werden wohl nur 2 verschiedene sein, daher auch nicht mehr als 2 Einträge in der map.</p>
<p>Und lass das greisliche &quot;using namespace std;&quot; weg, das ist IMHO ganz schlechter Stil <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/1155999</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1155999</guid><dc:creator><![CDATA[Plotzenhotz]]></dc:creator><pubDate>Tue, 17 Oct 2006 00:30:14 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamische Strukturen Array on Tue, 17 Oct 2006 07:09:23 GMT]]></title><description><![CDATA[<p>Und wie ich schon sagte - wenn die selbe Vokabel mehrfach vorkommen kann, nimm eine multimap anstelle der map (damit kann man fast genauso umgehen).</p>
<p>PS:</p>
<p>Plotzenhotz schrieb:</p>
<blockquote>
<p>Füge vor dem myVokabelMap.insert(...) folgendes ein:</p>
<pre><code class="language-cpp">std::cout &lt;&lt; &quot;[&quot; &lt;&lt; sLine.substr(0,pos-1) &lt;&lt; &quot;]&quot; &lt;&lt; std::endl &lt;&lt; std::flush;
</code></pre>
</blockquote>
<p>Das flush an dieser Stelle ist aber unnötig (endl flush't den Stream auch von sich aus).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1156011</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1156011</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Tue, 17 Oct 2006 07:09:23 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamische Strukturen Array on Tue, 17 Oct 2006 08:48:02 GMT]]></title><description><![CDATA[<p>Danke für eure tipps es geht jetzt alles wunderbar. doch leider habe ich eingesehen das map wohl doch nicht der<br />
richtige type für mich ist. Ich wollte nach den füllen der map schauen wieviel EInträge vorhanden sind und<br />
dann eine Zufalls zahl machen und nach dieser. z.b auf den 3 EIntrag zugreifen. diesen würde mir ja nur gelingen<br />
hatte ich eine ID oder ich würde ich schleife bis zu der Postion machne (schlecht idee den bei z.b dem 1000000 EIntrag)<br />
wird das ganze sehr langsam. Mit find() kann ich ja nur nach dem key suchen...</p>
<p>jemand ne idee für einen anderen Typen?</p>
<p>gruß</p>
<p>zyon</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1156087</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1156087</guid><dc:creator><![CDATA[zyon]]></dc:creator><pubDate>Tue, 17 Oct 2006 08:48:02 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamische Strukturen Array on Tue, 17 Oct 2006 08:54:13 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>wie wär's mit</p>
<pre><code class="language-cpp">vector&lt;pair&lt;string, string&gt; &gt;
</code></pre>
<p>?<br />
Dann kannst Du das Teil per &quot;Index&quot; zugreifen (auch ziemlich schnell) ..</p>
<p>Gruß,</p>
<p>Simon2.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1156092</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1156092</guid><dc:creator><![CDATA[Simon2]]></dc:creator><pubDate>Tue, 17 Oct 2006 08:54:13 GMT</pubDate></item></channel></rss>