<?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[Strukturfeld als referenzieller Parameter]]></title><description><![CDATA[<p>Hallo!</p>
<p>ich probiere jetzt schon seit langer Zeit. Ich moechte ein das tun, was im Titel steht. Hier mein Code:</p>
<pre><code class="language-cpp">// das ist mein Strukturfeld
point* bitmapLine;
...
// das wird initialisiert
point* bitmapLine = new point[MAXLINELENGTH];

// line() bekommt bitmapLine als Referenz, damit ich Werte da rein kopieren kann
line ((int)x, (int)y, x + rx2, y + ry2, &amp;bitmapLine);

// in line() erstelle ich buffer array p
void MCLControl::line( const int x1, const int y1, const int x2, const
int y2, point** bL) {
...
       point* p = new point[MAXLINELENGTH];

// und fuelle es
...
   for( int i = 0; i != dx; i += sdx ) {
           p[c].x = i + x1;
           p[c].y = m * i + y1;
           if (c == MAXLINELENGTH) { break; } else { c++; }
...
   for( int i = 0; i != dy; i += sdy ) {
           p[c].x = m * i + x1;
           p[c].y = i + y1;
           if (c == MAXLINELENGTH) { break; } else { c++; }
       }
 }

// jetzt kopiere ich es in meinen referenz - Parameter
  memcpy(bL, &amp;p, sizeof(point) * MAXLINELENGTH);
// und da gibts nen seg. fault
</code></pre>
<p>Ich habe auch schon versucht in line() mit</p>
<pre><code class="language-cpp">bl[c]-&gt;x = ...
</code></pre>
<p>versucht, ging aber irgendwie nicht.</p>
<p>Wenn ich bitmapLine als point**, also als Zeiger auf ein Array, deklariere, kann ich es nicht mit point** bitmapLine initialisieren. Und jetzt weiss ich nicht, was ich noch machen kann. Es muss doch eine Moeglichkeit geben, dass eine Funktion ein Feld von struct's fuellt!</p>
<p>viele Gruesse,<br />
Earl</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/133600/strukturfeld-als-referenzieller-parameter</link><generator>RSS for Node</generator><lastBuildDate>Thu, 27 Aug 2026 23:25:21 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/133600.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 19 Jan 2006 09:01:44 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Strukturfeld als referenzieller Parameter on Thu, 19 Jan 2006 09:01:44 GMT]]></title><description><![CDATA[<p>Hallo!</p>
<p>ich probiere jetzt schon seit langer Zeit. Ich moechte ein das tun, was im Titel steht. Hier mein Code:</p>
<pre><code class="language-cpp">// das ist mein Strukturfeld
point* bitmapLine;
...
// das wird initialisiert
point* bitmapLine = new point[MAXLINELENGTH];

// line() bekommt bitmapLine als Referenz, damit ich Werte da rein kopieren kann
line ((int)x, (int)y, x + rx2, y + ry2, &amp;bitmapLine);

// in line() erstelle ich buffer array p
void MCLControl::line( const int x1, const int y1, const int x2, const
int y2, point** bL) {
...
       point* p = new point[MAXLINELENGTH];

// und fuelle es
...
   for( int i = 0; i != dx; i += sdx ) {
           p[c].x = i + x1;
           p[c].y = m * i + y1;
           if (c == MAXLINELENGTH) { break; } else { c++; }
...
   for( int i = 0; i != dy; i += sdy ) {
           p[c].x = m * i + x1;
           p[c].y = i + y1;
           if (c == MAXLINELENGTH) { break; } else { c++; }
       }
 }

// jetzt kopiere ich es in meinen referenz - Parameter
  memcpy(bL, &amp;p, sizeof(point) * MAXLINELENGTH);
// und da gibts nen seg. fault
</code></pre>
<p>Ich habe auch schon versucht in line() mit</p>
<pre><code class="language-cpp">bl[c]-&gt;x = ...
</code></pre>
<p>versucht, ging aber irgendwie nicht.</p>
<p>Wenn ich bitmapLine als point**, also als Zeiger auf ein Array, deklariere, kann ich es nicht mit point** bitmapLine initialisieren. Und jetzt weiss ich nicht, was ich noch machen kann. Es muss doch eine Moeglichkeit geben, dass eine Funktion ein Feld von struct's fuellt!</p>
<p>viele Gruesse,<br />
Earl</p>
]]></description><link>https://www.c-plusplus.net/forum/post/970292</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/970292</guid><dc:creator><![CDATA[Earl(Gast)]]></dc:creator><pubDate>Thu, 19 Jan 2006 09:01:44 GMT</pubDate></item><item><title><![CDATA[Reply to Strukturfeld als referenzieller Parameter on Thu, 19 Jan 2006 09:18:16 GMT]]></title><description><![CDATA[<p>memcpy geht nur eine Indirektionsebene nach &quot;oben&quot;, d.h. mit deinem Aufruf kopierst du den Inhalt der Variable p auf bitmapline (bzw. bei deinen Größenangaben auch noch massenhaft Mülldaten in den Bereich hinter bitmapline). Richtig wäre</p>
<pre><code class="language-cpp">memcpy(*bL,p,sizeof(point)*MAXLINELENGTH);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/970307</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/970307</guid><dc:creator><![CDATA[CStoll (off)]]></dc:creator><pubDate>Thu, 19 Jan 2006 09:18:16 GMT</pubDate></item></channel></rss>