<?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[Anzahl der Arrays nacher definieren]]></title><description><![CDATA[<p>Ich habe nun einen Integer Array:</p>
<pre><code class="language-cpp">int Anzahl[x];
</code></pre>
<p>Nun möchte ich aber nicht, das schon am anfang definiet ist, wie viele Arrays es sind, sonder das die Anzahl immer um einen steigt, wenn ich einen neuen Array hin zu füge!</p>
<p>Also, beispielsweise so: (Pseudocode)</p>
<pre><code class="language-cpp">int Anzahl[undefinierte Größe];

for(int i = 0; i &lt; 100; i++)
{
    ArrayHinzufügen(Anzahl[undefinierte Größe]);
    Anzahl[i] = i;
}
</code></pre>
<p>Aber wie könnte ich dies nun machen?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/217726/anzahl-der-arrays-nacher-definieren</link><generator>RSS for Node</generator><lastBuildDate>Sat, 10 Oct 2026 09:45:53 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/217726.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 10 Jul 2008 13:08:32 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Anzahl der Arrays nacher definieren on Thu, 10 Jul 2008 13:08:32 GMT]]></title><description><![CDATA[<p>Ich habe nun einen Integer Array:</p>
<pre><code class="language-cpp">int Anzahl[x];
</code></pre>
<p>Nun möchte ich aber nicht, das schon am anfang definiet ist, wie viele Arrays es sind, sonder das die Anzahl immer um einen steigt, wenn ich einen neuen Array hin zu füge!</p>
<p>Also, beispielsweise so: (Pseudocode)</p>
<pre><code class="language-cpp">int Anzahl[undefinierte Größe];

for(int i = 0; i &lt; 100; i++)
{
    ArrayHinzufügen(Anzahl[undefinierte Größe]);
    Anzahl[i] = i;
}
</code></pre>
<p>Aber wie könnte ich dies nun machen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1545028</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1545028</guid><dc:creator><![CDATA[Showball]]></dc:creator><pubDate>Thu, 10 Jul 2008 13:08:32 GMT</pubDate></item><item><title><![CDATA[Reply to Anzahl der Arrays nacher definieren on Thu, 10 Jul 2008 13:14:26 GMT]]></title><description><![CDATA[<p>Hi,<br />
Du meinst du willst laufzeitdynamische array's haben???</p>
<p>Es gibt dafür zwo möglichkeiten:<br />
a)</p>
<pre><code class="language-cpp">int *lalaArray;
lalaArray= new int[anzahl];
delete[] lalaArray;
</code></pre>
<p>und b)</p>
<pre><code class="language-cpp">int *lalaArray;
lalaArray=(int*) malloc(sizeof(int)*anzahl);
free(lalaArray)
</code></pre>
<p>ich hoffe ich konnte helfen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1545031</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1545031</guid><dc:creator><![CDATA[zeusosc]]></dc:creator><pubDate>Thu, 10 Jul 2008 13:14:26 GMT</pubDate></item><item><title><![CDATA[Reply to Anzahl der Arrays nacher definieren on Thu, 10 Jul 2008 13:16:46 GMT]]></title><description><![CDATA[<p>Showball schrieb:</p>
<blockquote>
<p>Ich habe nun einen Integer Array:</p>
<pre><code class="language-cpp">int Anzahl[x];
</code></pre>
<p>Nun möchte ich aber nicht, das schon am anfang definiet ist, wie viele Arrays es sind, sonder das die Anzahl immer um einen steigt, wenn ich einen neuen Array hin zu füge!</p>
<p>Also, beispielsweise so: (Pseudocode)</p>
<pre><code class="language-cpp">int Anzahl[undefinierte Größe];

for(int i = 0; i &lt; 100; i++)
{
    ArrayHinzufügen(Anzahl[undefinierte Größe]);
    Anzahl[i] = i;
}
</code></pre>
<p>Aber wie könnte ich dies nun machen?</p>
</blockquote>
<p>Nimm einen std::vector&lt;int&gt; !!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1545032</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1545032</guid><dc:creator><![CDATA[bladerunner10]]></dc:creator><pubDate>Thu, 10 Jul 2008 13:16:46 GMT</pubDate></item><item><title><![CDATA[Reply to Anzahl der Arrays nacher definieren on Thu, 10 Jul 2008 13:24:02 GMT]]></title><description><![CDATA[<p>Beispiel:</p>
<pre><code class="language-cpp">#include &lt;vector&gt;

std::vector&lt;int&gt; Anzahl;
for(int i = 0; i &lt; 100; ++i)
{
   Anzahl.push_back(i);
}
</code></pre>
<p>oder:</p>
<pre><code class="language-cpp">std::vector&lt;int&gt; Anzahl(100);
for(int i = 0; i &lt; Anzahl.size(); ++i)
{
   Anzahl[i] = i;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1545039</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1545039</guid><dc:creator><![CDATA[Tachyon]]></dc:creator><pubDate>Thu, 10 Jul 2008 13:24:02 GMT</pubDate></item><item><title><![CDATA[Reply to Anzahl der Arrays nacher definieren on Thu, 10 Jul 2008 13:26:47 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">int *Array;

for(int i = 0; i &lt; 100; i++)
{
    Array = new int[1];
    Array[i] = 123;
}
</code></pre>
<p>Habe ich das richtig verstanden?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1545043</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1545043</guid><dc:creator><![CDATA[Showball]]></dc:creator><pubDate>Thu, 10 Jul 2008 13:26:47 GMT</pubDate></item><item><title><![CDATA[Reply to Anzahl der Arrays nacher definieren on Thu, 10 Jul 2008 13:26:59 GMT]]></title><description><![CDATA[<p>Siehe dazu auch <a href="http://www.cplusplus.com/reference/stl/vector/" rel="nofollow">http://www.cplusplus.com/reference/stl/vector/</a>.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1545044</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1545044</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Thu, 10 Jul 2008 13:26:59 GMT</pubDate></item><item><title><![CDATA[Reply to Anzahl der Arrays nacher definieren on Thu, 10 Jul 2008 13:29:10 GMT]]></title><description><![CDATA[<p>Showball schrieb:</p>
<blockquote>
<pre><code class="language-cpp">int *Array;

for(int i = 0; i &lt; 100; i++)
{
    Array = new int[1];
    Array[i] = 123;
}
</code></pre>
<p>Habe ich das richtig verstanden?</p>
</blockquote>
<p>Nein! Absolut nicht!</p>
<p>Nimm einen <strong>std::vector&lt;int&gt;</strong> !! Wirklich!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1545046</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1545046</guid><dc:creator><![CDATA[bladerunner10]]></dc:creator><pubDate>Thu, 10 Jul 2008 13:29:10 GMT</pubDate></item><item><title><![CDATA[Reply to Anzahl der Arrays nacher definieren on Thu, 10 Jul 2008 13:31:21 GMT]]></title><description><![CDATA[<p>Hmm, ich hoffe ihr habt mich rihtig verstanden, das mit dem Vektor dieht nähmlich so aus, als ob das auch fest definiert ist, nur das ich es nacher definieren kann.</p>
<p>Was ich bezwecken will, ist, das jedes mal wenn ich 1 Array mehr benötige, auch nur einen Array hin zu füge.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1545052</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1545052</guid><dc:creator><![CDATA[Showball]]></dc:creator><pubDate>Thu, 10 Jul 2008 13:31:21 GMT</pubDate></item><item><title><![CDATA[Reply to Anzahl der Arrays nacher definieren on Thu, 10 Jul 2008 13:35:33 GMT]]></title><description><![CDATA[<p>Tachyon hat recht,</p>
<p>bzgl. deines Probs solltest du stl::vec's benutzen da die sich automatisch vergößern.</p>
<p>edit:<br />
Ein array besteht wie der vec aus elementen, der vec vergrößert sich für den user während der laufzeit automatisch wenn du ein neues element am ende einfügst. Mit den standart array's müsstest du eine kopie mit größerer anzahl erstellen, dann dan altes hineinkopieren und das neue element hineinkopieren, das orig array dann freimachen, neu allocieren und dann die kopie ins neue packen etc.</p>
<p>Nimm stl:vec's</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1545053</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1545053</guid><dc:creator><![CDATA[zeusosc]]></dc:creator><pubDate>Thu, 10 Jul 2008 13:35:33 GMT</pubDate></item><item><title><![CDATA[Reply to Anzahl der Arrays nacher definieren on Thu, 10 Jul 2008 13:33:18 GMT]]></title><description><![CDATA[<p>Showball schrieb:</p>
<blockquote>
<p>Hmm, ich hoffe ihr habt mich rihtig verstanden, das mit dem Vektor dieht nähmlich so aus, als ob das auch fest definiert ist, nur das ich es nacher definieren kann.</p>
<p>Was ich bezwecken will, ist, das jedes mal wenn ich 1 Array mehr benötige, auch nur einen Array hin zu füge.</p>
</blockquote>
<p>So, und jetzt sag noch einmal genau, was dein Problem ist bzw. was du erreichen<br />
möchtest.<br />
Du möchtest kein Array hinzufügen, das mach keinen Sinn.</p>
<p>Also?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1545056</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1545056</guid><dc:creator><![CDATA[bladerunner10]]></dc:creator><pubDate>Thu, 10 Jul 2008 13:33:18 GMT</pubDate></item><item><title><![CDATA[Reply to Anzahl der Arrays nacher definieren on Thu, 10 Jul 2008 13:33:37 GMT]]></title><description><![CDATA[<p>Falls du wirklich eigene dynamische Arrays haben willst (zu Übungszwecken), solltest du dich <strong>unbedingt</strong> zuerst ausführlich mit Zeigern und dynamischer Speicherverwaltung befassen. Denn so bekommst du spätestens beim sauberen Freigeben wieder Probleme.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1545057</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1545057</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Thu, 10 Jul 2008 13:33:37 GMT</pubDate></item><item><title><![CDATA[Reply to Anzahl der Arrays nacher definieren on Thu, 10 Jul 2008 13:37:49 GMT]]></title><description><![CDATA[<p>Schon gut, ich sehe grad das das mit den Vecs genau das richtige ist, danke!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1545062</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1545062</guid><dc:creator><![CDATA[Showball]]></dc:creator><pubDate>Thu, 10 Jul 2008 13:37:49 GMT</pubDate></item><item><title><![CDATA[Reply to Anzahl der Arrays nacher definieren on Thu, 10 Jul 2008 13:39:44 GMT]]></title><description><![CDATA[<p>Showball schrieb:</p>
<blockquote>
<p>Hmm, ich hoffe ihr habt mich rihtig verstanden, das mit dem Vektor dieht nähmlich so aus, als ob das auch fest definiert ist, nur das ich es nacher definieren kann.</p>
<p>Was ich bezwecken will, ist, das jedes mal wenn ich 1 Array mehr benötige, auch nur einen Array hin zu füge.</p>
</blockquote>
<p>Genau das tust Du mit push_back...</p>
<pre><code class="language-cpp">#include &lt;vector&gt;

std::vector&lt;int&gt; Anzahl;  //hier ist der Vektor noch leer...

for(int i = 0; i &lt; 100; ++i)
{
   //bei jedem Durchlauf wird ein Element hinzugefuegt. 
   //Bei i=0 ist also ein Element im vektor, bei i=1 2 Elemente usw.
   Anzahl.push_back(i); 
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1545066</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1545066</guid><dc:creator><![CDATA[Tachyon]]></dc:creator><pubDate>Thu, 10 Jul 2008 13:39:44 GMT</pubDate></item><item><title><![CDATA[Reply to Anzahl der Arrays nacher definieren on Thu, 10 Jul 2008 13:52:32 GMT]]></title><description><![CDATA[<p>Tachyon schrieb:</p>
<blockquote>
<p>Showball schrieb:</p>
<blockquote>
<p>Hmm, ich hoffe ihr habt mich rihtig verstanden, das mit dem Vektor dieht nähmlich so aus, als ob das auch fest definiert ist, nur das ich es nacher definieren kann.</p>
<p>Was ich bezwecken will, ist, das jedes mal wenn ich 1 Array mehr benötige, auch nur einen Array hin zu füge.</p>
</blockquote>
<p>Genau das tust Du mit push_back...</p>
</blockquote>
<p>Jein...<br />
Es ist nicht garantiert, das genau ein (nennen wir es mal) <em>Eintrag</em> hinzugefügt wird. Stichwort <em>Größe</em> vs. <em>Kapazität</em></p>
<p>EDIT: Es wird genau ein Eintrag hinzugefügt, aber evtl. (sehr wahrscheinlich...) Platz für mehr Einträge alloziert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1545070</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1545070</guid><dc:creator><![CDATA[bladerunner10]]></dc:creator><pubDate>Thu, 10 Jul 2008 13:52:32 GMT</pubDate></item><item><title><![CDATA[Reply to Anzahl der Arrays nacher definieren on Thu, 10 Jul 2008 13:44:58 GMT]]></title><description><![CDATA[<p>bladerunner10 schrieb:</p>
<blockquote>
<p>Tachyon schrieb:</p>
<blockquote>
<p>Showball schrieb:</p>
<blockquote>
<p>Hmm, ich hoffe ihr habt mich rihtig verstanden, das mit dem Vektor dieht nähmlich so aus, als ob das auch fest definiert ist, nur das ich es nacher definieren kann.</p>
<p>Was ich bezwecken will, ist, das jedes mal wenn ich 1 Array mehr benötige, auch nur einen Array hin zu füge.</p>
</blockquote>
<p>Genau das tust Du mit push_back...</p>
</blockquote>
<p>Jein...<br />
Es ist nicht garantiert, das genau ein (nennen wir es mal) <em>Eintrag</em> hinzugefügt wird. Stichwort <em>Größe</em> vs. <em>Kapazität</em></p>
</blockquote>
<p>Natürlich wird genau ein Eintrag hinzugefügt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1545071</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1545071</guid><dc:creator><![CDATA[Tachyon]]></dc:creator><pubDate>Thu, 10 Jul 2008 13:44:58 GMT</pubDate></item><item><title><![CDATA[Reply to Anzahl der Arrays nacher definieren on Thu, 10 Jul 2008 13:47:41 GMT]]></title><description><![CDATA[<p>Was bladerunner meint ist wenn die unglaublich kleine capacität von 99 überschritten wird wenn man den hundertsten eintrag hinzufügt.</p>
<p>Grüße</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1545077</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1545077</guid><dc:creator><![CDATA[zeusosc]]></dc:creator><pubDate>Thu, 10 Jul 2008 13:47:41 GMT</pubDate></item><item><title><![CDATA[Reply to Anzahl der Arrays nacher definieren on Thu, 10 Jul 2008 13:50:01 GMT]]></title><description><![CDATA[<p>zeusosc schrieb:</p>
<blockquote>
<p>Was bladerunner meint ist wenn die unglaublich kleine capacität von 99 überschritten wird wenn man den hundertsten eintrag hinzufügt.</p>
<p>Grüße</p>
</blockquote>
<p>Er hat es aber nicht so gesagt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1545081</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1545081</guid><dc:creator><![CDATA[Tachyon]]></dc:creator><pubDate>Thu, 10 Jul 2008 13:50:01 GMT</pubDate></item><item><title><![CDATA[Reply to Anzahl der Arrays nacher definieren on Thu, 10 Jul 2008 13:57:38 GMT]]></title><description><![CDATA[<p>Tachyon schrieb:</p>
<blockquote>
<p>Er hat es aber nicht so gesagt.</p>
</blockquote>
<p>bladerunner10 schrieb:</p>
<blockquote>
<p>Stichwort <em>Größe</em> vs. <em>Kapazität</em></p>
</blockquote>
<p>Ich denke durch kurzes Überlegen könnte man es so interpretieren <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>Noch etwas zur Begrifflichkeit: Ein <strong>Array</strong> (auch Feld genannt) ist <strong>NICHT</strong> dasselbe wie ein Element oder ein Eintrag, sondern die ganze Struktur an sich.</p>
<pre><code class="language-cpp">int arr[43];  // arr ist ein Array mit 43 Integer-Werten
arr[0];       // arr[0] ist das erste Element des Arrays arr, und KEIN ARRAY!!
</code></pre>
<p>Genau so wenig kann man einem eindimensionalen Vektor ein Array mit <code>push_back</code> hinzufügen, sondern nur einen Eintrag/einen Wert/ein Element.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1545091</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1545091</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Thu, 10 Jul 2008 13:57:38 GMT</pubDate></item></channel></rss>