<?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[Strukturen...]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>ich habe eine Frage zu einem Programm</p>
<pre><code class="language-cpp">struct punkt_struct
{
  float x;
  float y;
};

typedef struct punkt_struct punkt;

void getPunkte(punkt thePunkte[], int len)
{
  double t=0;

  for( t = 0.0 ; t &lt; len; t++)
  {
    thePunkte[(int)t].x = (float)t;
    thePunkte[(int)t].y = (float)sin(t*0.1); 
  }
}

void printPunkte(punkt thePunkte[], int len)
{
  int t=0;

  for( t = 0 ; t &lt; len; t++)
  {
    printf(&quot;(x,y)=(%f,%f)\n&quot;,thePunkte[t].x ,thePunkte[t].y);
  }
}

punkt getGreater(punkt p1, punkt p2)
{
  if (p1.y &gt;= p2.y)
  {
    return p1;
  }
  return p2;
}

punkt findMax(punkt thePunkte[], int len)
{
  int t=0;
  punkt maxValue;

  maxValue=thePunkte[0];
  for( t = 0 ; t &lt; len; t++)
  {
    maxValue = getGreater(thePunkte[t],maxValue);
//Soll das der Unterprogrammaufruf sein von punkt get creater? warum schreibt //man hier thepunkte und maxValue rein. Ich dachte immer man muss die //Übergabeparameter hineinschreiben: p1 und p2 in meinem Fall?
  }
  return maxValue;
}

void main()
{
  ....
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/293671/strukturen</link><generator>RSS for Node</generator><lastBuildDate>Wed, 11 Nov 2026 22:53:56 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/293671.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 08 Oct 2011 09:51:49 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Strukturen... on Sat, 08 Oct 2011 09:51:49 GMT]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>ich habe eine Frage zu einem Programm</p>
<pre><code class="language-cpp">struct punkt_struct
{
  float x;
  float y;
};

typedef struct punkt_struct punkt;

void getPunkte(punkt thePunkte[], int len)
{
  double t=0;

  for( t = 0.0 ; t &lt; len; t++)
  {
    thePunkte[(int)t].x = (float)t;
    thePunkte[(int)t].y = (float)sin(t*0.1); 
  }
}

void printPunkte(punkt thePunkte[], int len)
{
  int t=0;

  for( t = 0 ; t &lt; len; t++)
  {
    printf(&quot;(x,y)=(%f,%f)\n&quot;,thePunkte[t].x ,thePunkte[t].y);
  }
}

punkt getGreater(punkt p1, punkt p2)
{
  if (p1.y &gt;= p2.y)
  {
    return p1;
  }
  return p2;
}

punkt findMax(punkt thePunkte[], int len)
{
  int t=0;
  punkt maxValue;

  maxValue=thePunkte[0];
  for( t = 0 ; t &lt; len; t++)
  {
    maxValue = getGreater(thePunkte[t],maxValue);
//Soll das der Unterprogrammaufruf sein von punkt get creater? warum schreibt //man hier thepunkte und maxValue rein. Ich dachte immer man muss die //Übergabeparameter hineinschreiben: p1 und p2 in meinem Fall?
  }
  return maxValue;
}

void main()
{
  ....
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2128785</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2128785</guid><dc:creator><![CDATA[theguest123]]></dc:creator><pubDate>Sat, 08 Oct 2011 09:51:49 GMT</pubDate></item><item><title><![CDATA[Reply to Strukturen... on Sat, 08 Oct 2011 10:15:39 GMT]]></title><description><![CDATA[<p><code>punkt getGreater(punkt p1, punkt p2)</code> erwartet zwei Parameter vom TYp punkt.</p>
<p><code>thePunkte[t]</code> ist vom Typ punkt.<br />
<code>maxValue</code> ist vom Typ punkt.</p>
<p>Also ist <code>maxValue = getGreater(thePunkte[t],maxValue);</code> richtig.</p>
<p>Wo ist das Problem?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2128799</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2128799</guid><dc:creator><![CDATA[DirkB]]></dc:creator><pubDate>Sat, 08 Oct 2011 10:15:39 GMT</pubDate></item><item><title><![CDATA[Reply to Strukturen... on Sat, 08 Oct 2011 10:17:01 GMT]]></title><description><![CDATA[<p>Beim Aufruf mußt du angeben, mit welchen Werten die Funktion arbeiten soll. Das heißt in deinem Beispiel übergibst du thePunkte[t] und maxValue an die Funktion, die diese dann unter den Namen p1 bzw. p2 ansprechen kann.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2128801</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2128801</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Sat, 08 Oct 2011 10:17:01 GMT</pubDate></item><item><title><![CDATA[Reply to Strukturen... on Sat, 08 Oct 2011 10:49:02 GMT]]></title><description><![CDATA[<p>Danke und warum ändert man da die namen um?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2128808</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2128808</guid><dc:creator><![CDATA[theguest123]]></dc:creator><pubDate>Sat, 08 Oct 2011 10:49:02 GMT</pubDate></item><item><title><![CDATA[Reply to Strukturen... on Sat, 08 Oct 2011 12:21:14 GMT]]></title><description><![CDATA[<p>Weil du beim Schreiben der Funktion nicht wissen kannst, wer und wo sie später nutzen will. Die Funktionsdeklaration gibt nur an, daß sie zwei <code>punkt</code> -Structs entgegennehmen will und der Anwender definiert sich die Variablen und wirft sie in die Funktion rein. (die Namen der Parameter sind nur innerhalb der Funktion relevant)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2128869</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2128869</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Sat, 08 Oct 2011 12:21:14 GMT</pubDate></item><item><title><![CDATA[Reply to Strukturen... on Sun, 09 Oct 2011 15:25:37 GMT]]></title><description><![CDATA[<p>Ok, danke.</p>
<p>Nun hab ich ein Programm mit Zeigern. Eigentlich kann man sgaen das ein Zeiger fast das gleiche ist wie ein Array, oder eine Struktur?</p>
<pre><code class="language-cpp">void getPunkte(punkt* thePunkte, int len)
{
  double t=0;

  for( t = 0.0 ; t &lt; len; t++)
  {
    thePunkte-&gt;x = (float)t;//thepunkte zeigt auf x / thePunkte.x ist aber fast 
// das gleiche oder?
    thePunkte-&gt;y = (float)sin(t*0.1+1.4); 
    thePunkte++;
  }
}

void printPunkte(punkt thePunkte[], int len)
{
  int t=0;

  for( t = 0 ; t &lt; len; t++)
  {
    printf(&quot;(x,y)=(%f,%f)\n&quot;,thePunkte[t].x ,thePunkte[t].y);
  }
}
</code></pre>
<p>Dann gibts ja noch dieses &quot;&amp;&quot; das wandelt was um, aber weis net genau?<br />
*<br />
Und der * weist hin das es ein Zeiger ist, Also: int *zeiger</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2129269</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2129269</guid><dc:creator><![CDATA[theguest123]]></dc:creator><pubDate>Sun, 09 Oct 2011 15:25:37 GMT</pubDate></item><item><title><![CDATA[Reply to Strukturen... on Sun, 09 Oct 2011 15:40:23 GMT]]></title><description><![CDATA[<p>theguest123 schrieb:</p>
<blockquote>
<p>Eigentlich kann man sgaen das ein Zeiger fast das gleiche ist wie ein Array, oder eine Struktur?</p>
</blockquote>
<p>Nein.</p>
<p>Ein Zeiger enthält eine Adresse.<br />
Über eine Adresse kannst du auf Objekte (Variablen, Strukturen) im Speicher zugreifen.<br />
Bei einer Variablen ist diese Adresse fest an den Variablennamen gebunden.<br />
Bei einem Zeiger kannst du Adresse ändern und somit auf ander Objekte (des gleichen Typs) zeigen.</p>
<p>theguest123 schrieb:</p>
<blockquote>
<p>Dann gibts ja noch dieses &quot;&amp;&quot; das wandelt was um, aber weis net genau?<br />
*<br />
Und der * weist hin das es ein Zeiger ist, Also: int *zeiger</p>
</blockquote>
<p>Das &amp; liefert dir die Adresse von einem Objekt.<br />
Der * ist der Dereferenzierungsoperator. Damit greifst du auf den Inhalt an der Adresse zu.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2129273</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2129273</guid><dc:creator><![CDATA[DirkB]]></dc:creator><pubDate>Sun, 09 Oct 2011 15:40:23 GMT</pubDate></item></channel></rss>