<?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 array loop]]></title><description><![CDATA[<p>Hallo,<br />
ich habe einen struct der Form:</p>
<pre><code>typedef struct zuor
{
	char 	*name;
	int 	*fkt;
	int	Fall1;
	int 	Fall2;
	int	Fall3;
	int	Fall4;
}posi;

posi test[]=
{
  {&quot;Test1&quot;, &amp;get1, 3, 2, 1, 0 },
  {&quot;Test2&quot;, &amp;get2, 9, 8, 7, 6 },
}
</code></pre>
<p>Nun möchte ich auf Fall 1 bis 4 nicht via test[0].Fall1, test[0].Fall2 etc. zugreifen, sondern durch eine for-Schleife.<br />
test[0].2 etc. funktioniert nicht aber gibt es vielleicht eine andere Möglichkeit?<br />
Kann man nicht vielleicht notfalls einen String zur Variablen zusammenbauen oder so (nicht zur Laufzeit)?<br />
Danke für eure Hilfe!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/324998/struct-array-loop</link><generator>RSS for Node</generator><lastBuildDate>Mon, 13 Jul 2026 07:58:32 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/324998.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 10 Apr 2014 16:04:50 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to struct array loop on Thu, 10 Apr 2014 16:04:50 GMT]]></title><description><![CDATA[<p>Hallo,<br />
ich habe einen struct der Form:</p>
<pre><code>typedef struct zuor
{
	char 	*name;
	int 	*fkt;
	int	Fall1;
	int 	Fall2;
	int	Fall3;
	int	Fall4;
}posi;

posi test[]=
{
  {&quot;Test1&quot;, &amp;get1, 3, 2, 1, 0 },
  {&quot;Test2&quot;, &amp;get2, 9, 8, 7, 6 },
}
</code></pre>
<p>Nun möchte ich auf Fall 1 bis 4 nicht via test[0].Fall1, test[0].Fall2 etc. zugreifen, sondern durch eine for-Schleife.<br />
test[0].2 etc. funktioniert nicht aber gibt es vielleicht eine andere Möglichkeit?<br />
Kann man nicht vielleicht notfalls einen String zur Variablen zusammenbauen oder so (nicht zur Laufzeit)?<br />
Danke für eure Hilfe!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2393868</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2393868</guid><dc:creator><![CDATA[Beneroli]]></dc:creator><pubDate>Thu, 10 Apr 2014 16:04:50 GMT</pubDate></item><item><title><![CDATA[Reply to struct array loop on Thu, 10 Apr 2014 16:13:22 GMT]]></title><description><![CDATA[<p>nein, kann man nicht. zur laufzeit gibt es die bezeichner gar nicht mehr. mach die fälle einfach zu einem array aus vier ints:</p>
<pre><code>#include &lt;iostream&gt;
struct posi
{
    char    *name;
    int     *fkt;
    int Fall[4];
};

int main()
{
    posi Foo;
    for(std::size_t i = 0; i &lt; 4; ++i)
        std::cout &lt;&lt; Foo.Fall[i];
}
</code></pre>
<p>ps.: das was du da mit typedef struct machst ist c und in c++ nicht mehr nötig.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2393870</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2393870</guid><dc:creator><![CDATA[Fytch]]></dc:creator><pubDate>Thu, 10 Apr 2014 16:13:22 GMT</pubDate></item></channel></rss>