<?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[array aus strukturen]]></title><description><![CDATA[<p>hallo,</p>
<p>ich habe eine structur der form:</p>
<pre><code>struct struktur{
    int var1;
    int var2;
    int var3;
}
</code></pre>
<p>ich brauche nun eine ganze menge von diesen strukturen.</p>
<p>nun wollte ich ein array machen und die arrayelemente sollten diese strukturen sein. leider bekomme ich das irgendwie nicht hin.<br />
oder könnte man das auch noch anders lösen?</p>
<p>Gruß<br />
Steffen</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/124209/array-aus-strukturen</link><generator>RSS for Node</generator><lastBuildDate>Sun, 23 Aug 2026 21:04:12 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/124209.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 24 Oct 2005 19:48:32 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to array aus strukturen on Mon, 24 Oct 2005 19:48:32 GMT]]></title><description><![CDATA[<p>hallo,</p>
<p>ich habe eine structur der form:</p>
<pre><code>struct struktur{
    int var1;
    int var2;
    int var3;
}
</code></pre>
<p>ich brauche nun eine ganze menge von diesen strukturen.</p>
<p>nun wollte ich ein array machen und die arrayelemente sollten diese strukturen sein. leider bekomme ich das irgendwie nicht hin.<br />
oder könnte man das auch noch anders lösen?</p>
<p>Gruß<br />
Steffen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/900387</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/900387</guid><dc:creator><![CDATA[Jörgi]]></dc:creator><pubDate>Mon, 24 Oct 2005 19:48:32 GMT</pubDate></item><item><title><![CDATA[Reply to array aus strukturen on Mon, 24 Oct 2005 20:01:19 GMT]]></title><description><![CDATA[<p>Meinst du so was:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;

struct struktur{ 
    int var1; 
    int var2; 
    int var3; 
};

int main( int argc, char **argv )
{
	struktur str[3];

	return 0;
}
</code></pre>
<p>Wenn die Anzahl der Strukturen fix ist, die du machen musst, dann ist ein Array ok.<br />
Wenn die Anzahl dynamisch ist dann wuerde ich eher eine Liste nehmen (std::list)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/900392</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/900392</guid><dc:creator><![CDATA[moe szyslak]]></dc:creator><pubDate>Mon, 24 Oct 2005 20:01:19 GMT</pubDate></item><item><title><![CDATA[Reply to array aus strukturen on Mon, 24 Oct 2005 20:02:37 GMT]]></title><description><![CDATA[<p>wenn ich das richtig verstehe habe ich nun ein array mit vier elementen. jedes element ist eine struktur, wie sie vorher angegeben wurde.</p>
<p>wie kann ich denn dann auf die einzelnen variablen in den strukturen zugreifen?<br />
str[1].var1?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/900394</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/900394</guid><dc:creator><![CDATA[Jörgi]]></dc:creator><pubDate>Mon, 24 Oct 2005 20:02:37 GMT</pubDate></item><item><title><![CDATA[Reply to array aus strukturen on Mon, 24 Oct 2005 20:07:50 GMT]]></title><description><![CDATA[<p>Du hast im Beispiel ein Array mit 3 Elementen (der Index beginnt bei 0, dann 1, dann 2). 3 Gibt die Anzahl an, wieviele Elemente dein Array haben soll.<br />
Der Zugriff erfolgt so:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;

struct struktur{ 
    int var1; 
    int var2; 
    int var3; 
};

int main( int argc, char **argv )
{
	struktur str[3];

	str[0].var1 = 3;

	std::cout &lt;&lt; str[0].var1 &lt;&lt; std::endl;

	return 0;
}
</code></pre>
<p>Das Array enthaelt dann natuerlich 3 mal deine Struktur - verbleichbar mit<br />
int var[3]<br />
das ist ein Array aus 3 Integer-Werten. Das heisst du koenntest deine Struktur auch so schreiben:</p>
<pre><code class="language-cpp">struct struktur{ 
    int var[3];
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/900397</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/900397</guid><dc:creator><![CDATA[moe szyslak]]></dc:creator><pubDate>Mon, 24 Oct 2005 20:07:50 GMT</pubDate></item><item><title><![CDATA[Reply to array aus strukturen on Mon, 24 Oct 2005 20:06:56 GMT]]></title><description><![CDATA[<p>Ah,</p>
<p>vielen Dank!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/900398</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/900398</guid><dc:creator><![CDATA[Jörgi]]></dc:creator><pubDate>Mon, 24 Oct 2005 20:06:56 GMT</pubDate></item><item><title><![CDATA[Reply to array aus strukturen on Mon, 24 Oct 2005 20:22:48 GMT]]></title><description><![CDATA[<p>ich weiß nun nicht, wie viele strukturen ich benötigen werde.<br />
so wollte ich die klammern [] leer lassen. dann bekomme ich allerdings ne fehlermeldung. scheib ich eine zahl rein, dann gehts.</p>
<p>muss man die zahl direkt angeben oder kann man das auch noch anders lösen, wenn vorher nicht weiß, wievil man davon benötigt?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/900413</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/900413</guid><dc:creator><![CDATA[Jörgi]]></dc:creator><pubDate>Mon, 24 Oct 2005 20:22:48 GMT</pubDate></item><item><title><![CDATA[Reply to array aus strukturen on Mon, 24 Oct 2005 20:28:33 GMT]]></title><description><![CDATA[<p>Mit Pointer und dynamische Speicherreservierung.</p>
<pre><code class="language-cpp">Struktur *arr; // Pointer
arr = new Struktur[anzahl];  // Speicher für &lt;anzahl&gt; Strukturen belegen
</code></pre>
<p>edit:</p>
<p>Natürlich net vergessen Speicher wieder freizugeben wenn du möchtest:</p>
<pre><code class="language-cpp">delete[] arr;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/900418</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/900418</guid><dc:creator><![CDATA[effe_eichelt]]></dc:creator><pubDate>Mon, 24 Oct 2005 20:28:33 GMT</pubDate></item><item><title><![CDATA[Reply to array aus strukturen on Mon, 24 Oct 2005 21:03:18 GMT]]></title><description><![CDATA[<p>wie knn ich denn dann darauf zugreifen?<br />
ich habe z.b folgendes erstellt</p>
<p>Struktur *str; // Pointer<br />
str = new Struktur[anzahl]; // Speicher für &lt;anzahl&gt; Strukturen belegen</p>
<p>nun möchte ich eine struktur füllen</p>
<p>bei str.var1[ii]= 0; (wobei ii z.B. 0) ist gibts probleme. ich steig da noch nicht so ganz dahinter.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/900441</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/900441</guid><dc:creator><![CDATA[Jörgi]]></dc:creator><pubDate>Mon, 24 Oct 2005 21:03:18 GMT</pubDate></item><item><title><![CDATA[Reply to array aus strukturen on Mon, 24 Oct 2005 21:17:27 GMT]]></title><description><![CDATA[<p>Das macht man wie zuvor:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;

struct Struktur{ 
    int var[3];
};

int main( int argc, char **argv )
{
	Struktur *str; // Pointer 
	int anzahl = 3;
	str = new Struktur[anzahl]; // Speicher für &lt;anzahl&gt; Strukturen belegen 
	str[0].var[0] = 3;
	std::cout &lt;&lt; str[0].var[0] &lt;&lt; std::endl;
	delete( str );

	return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/900448</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/900448</guid><dc:creator><![CDATA[moe szyslak]]></dc:creator><pubDate>Mon, 24 Oct 2005 21:17:27 GMT</pubDate></item><item><title><![CDATA[Reply to array aus strukturen on Tue, 25 Oct 2005 05:26:46 GMT]]></title><description><![CDATA[<p>Die objektorientierte, evtl. elegantere Implementierung würde sich auf die Dynamischen Containerklassen der Standardbibliothek stützen. Schau dir mal das entsprechende Kapitel in deiner C++-Referenz an...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/900504</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/900504</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Tue, 25 Oct 2005 05:26:46 GMT</pubDate></item></channel></rss>