<?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[Semantischer fehler.....woran liegt das?]]></title><description><![CDATA[<p>Hi,<br />
ich habe folgendes Problem.....habe hier ein kleines Beispiel:</p>
<pre><code class="language-cpp">#include &quot;stdio.h&quot;
#include &quot;stdlib.h&quot;
#include &quot;conio.h&quot;

using namespace std;

int fillImageOrdered (int arr[], int mWidth, int mHeight);
void showImage (int arr[], int mWidth, int mHeight);

int main (void)
{
  int *Map;
  int mWidth=10;
  int mHeight=10;
  int x,y;

  Map = (int*)malloc(sizeof(int) * (mWidth * mHeight + 2)); 

fillImageOrdered (Map,mWidth,mHeight);
showImage (Map,mWidth,mHeight);

  getch();
return 0;
}

void showImage (int *Map, int mWidth, int mHeight){
     int x,y;
  for(x = 0; x &lt; mWidth; x++){
    for(y = 0; y &lt; mHeight; y++){
      printf(&quot;%d\t&quot;,Map[x+y]);
                                }
    printf(&quot;\n&quot;);
                             }
     }

int fillImageOrdered (int *Map, int mWidth, int mHeight){
  int value=0;int x,y;
  for(x = 0; x &lt; mWidth; x++){
    for(y = 0; y &lt; mHeight; y++){
      *(Map+x+y)= value;value++;}
                             }

                                    return *Map;            }
</code></pre>
<p>nun sollte aber beim Funktionsaufruf &quot;showImage&quot; meiner Meinung nach 0,1,2,3,4..usw.bis 99 ausgegeben werden.....</p>
<p>woran liegt denn das bitte? wahrscheinlich is es irgendwas dummes was ich die ganze Zeit übersehe, aber ich komm nicht drauf:(</p>
<p>thx for help<br />
lg holzi</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/255847/semantischer-fehler-woran-liegt-das</link><generator>RSS for Node</generator><lastBuildDate>Fri, 11 Sep 2026 19:58:52 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/255847.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 04 Dec 2009 12:03:57 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Semantischer fehler.....woran liegt das? on Fri, 04 Dec 2009 12:03:57 GMT]]></title><description><![CDATA[<p>Hi,<br />
ich habe folgendes Problem.....habe hier ein kleines Beispiel:</p>
<pre><code class="language-cpp">#include &quot;stdio.h&quot;
#include &quot;stdlib.h&quot;
#include &quot;conio.h&quot;

using namespace std;

int fillImageOrdered (int arr[], int mWidth, int mHeight);
void showImage (int arr[], int mWidth, int mHeight);

int main (void)
{
  int *Map;
  int mWidth=10;
  int mHeight=10;
  int x,y;

  Map = (int*)malloc(sizeof(int) * (mWidth * mHeight + 2)); 

fillImageOrdered (Map,mWidth,mHeight);
showImage (Map,mWidth,mHeight);

  getch();
return 0;
}

void showImage (int *Map, int mWidth, int mHeight){
     int x,y;
  for(x = 0; x &lt; mWidth; x++){
    for(y = 0; y &lt; mHeight; y++){
      printf(&quot;%d\t&quot;,Map[x+y]);
                                }
    printf(&quot;\n&quot;);
                             }
     }

int fillImageOrdered (int *Map, int mWidth, int mHeight){
  int value=0;int x,y;
  for(x = 0; x &lt; mWidth; x++){
    for(y = 0; y &lt; mHeight; y++){
      *(Map+x+y)= value;value++;}
                             }

                                    return *Map;            }
</code></pre>
<p>nun sollte aber beim Funktionsaufruf &quot;showImage&quot; meiner Meinung nach 0,1,2,3,4..usw.bis 99 ausgegeben werden.....</p>
<p>woran liegt denn das bitte? wahrscheinlich is es irgendwas dummes was ich die ganze Zeit übersehe, aber ich komm nicht drauf:(</p>
<p>thx for help<br />
lg holzi</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1817779</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1817779</guid><dc:creator><![CDATA[H0lzi]]></dc:creator><pubDate>Fri, 04 Dec 2009 12:03:57 GMT</pubDate></item><item><title><![CDATA[Reply to Semantischer fehler.....woran liegt das? on Fri, 04 Dec 2009 12:49:04 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">*(Map+x+y)= value
</code></pre>
<p>Ueber diese Zeile solltest du nochmal nachdenken.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1817780</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1817780</guid><dc:creator><![CDATA[knivil]]></dc:creator><pubDate>Fri, 04 Dec 2009 12:49:04 GMT</pubDate></item><item><title><![CDATA[Reply to Semantischer fehler.....woran liegt das? on Fri, 04 Dec 2009 12:22:27 GMT]]></title><description><![CDATA[<p>thx knivil für die schnelle Antwort!<br />
Wie könnte ich denn das anders machen?</p>
<p>Irgendwie hänge ich die ganze Zeit an dam selben Problem.....ich war überzeugt , dass das Problem irgendwie durch die return Anweisung entsteht...da das ergebniss von :</p>
<pre><code class="language-cpp">int value=0;
  for(x = 0; x &lt; mWidth; x++){
    for(y = 0; y &lt; mHeight; y++){
      *(Map+x+y)= value;value++;
      printf(&quot;%d\t&quot;,Map[x+y]);
    }
    printf(&quot;\n&quot;);
  }
</code></pre>
<p>in der main genau das gewünschte ist....... nur in einem seperaten Methodenaufruf kommt eine mir nicht nachvollziehbare Zahlenfolge zum Vorschein leider*gg*.</p>
<p>gibt es eine effizientere Methode als</p>
<pre><code>*(Map+x+y)= value;
</code></pre>
<p>um den gewünschten Sektor des arr[] anzusprechen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1817789</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1817789</guid><dc:creator><![CDATA[H0lzi]]></dc:creator><pubDate>Fri, 04 Dec 2009 12:22:27 GMT</pubDate></item><item><title><![CDATA[Reply to Semantischer fehler.....woran liegt das? on Fri, 04 Dec 2009 12:42:29 GMT]]></title><description><![CDATA[<p>H0lzi schrieb:</p>
<blockquote>
<p>gibt es eine effizientere Methode als</p>
<pre><code>*(Map+x+y)= value;
</code></pre>
<p>um den gewünschten Sektor des arr[] anzusprechen?</p>
</blockquote>
<p>naja - wie wär's denn erstmal mit der richtigen statt mit einer effizienteren Methode. Wenn ich das richtig verstehe soll das doch eine Art Matrix mit mWidth Spalten und mHeight Yeilen werden. x läuft über die Spalten und z über die Zeilen.<br />
Mal angenommen die Matrix ist Spaltenweise im Speicher abgelegt dann läuft y schneller - d.h. in der inneren Schleife. Dann wäre fillImageOrdered:</p>
<pre><code class="language-cpp">int fillImageOrdered( int *Map, int mWidth, int mHeight){
    int value=0;
    for( int x = 0; x &lt; mWidth; ++x )
    {
        for( int y = 0; y &lt; mHeight; ++y, ++value)
            *Map++= value;
    }
    return *Map; // zeigt jetzt hinter das Ende der Map      
}
</code></pre>
<p>jetzt überlege nochmal was in Zeile 33 geschehen muss.</p>
<p>PS.: :xmas2: ist denn schon wieder Weihnachten?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1817805</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1817805</guid><dc:creator><![CDATA[Werner_logoff]]></dc:creator><pubDate>Fri, 04 Dec 2009 12:42:29 GMT</pubDate></item><item><title><![CDATA[Reply to Semantischer fehler.....woran liegt das? on Fri, 04 Dec 2009 12:50:07 GMT]]></title><description><![CDATA[<p>Zum einen ist 3 + 5 das gleiche wie 5 + 3, aber der Pixel an Stelle (5,3) ist nicht der gleiche wie an (3,5). Ich interpretiere deinen Code so, dass du ein zweidimensionales &quot;Objekt&quot; (sprich Bild/Image) hast und du es in einem eindimensionalen Array (Vektor or what ever) gespeichert hast. Der Zugriff auf Pixel (x,y) erfolgt dabei durch die Abbildung (x,y) -&gt; (x*mWidth + y) (oder (x,y) -&gt; y*mHeight + x). Je nachdem ob du dein Bild zeilen- oder spaltenorientiert ablegst (und je nachdem, was ueberhaupt Zeile oder Spalte repraesentiert). Der Code dafuer sieht so aus:</p>
<pre><code class="language-cpp">Map[x*mWidth+y] = value
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1817812</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1817812</guid><dc:creator><![CDATA[knivil]]></dc:creator><pubDate>Fri, 04 Dec 2009 12:50:07 GMT</pubDate></item><item><title><![CDATA[Reply to Semantischer fehler.....woran liegt das? on Fri, 04 Dec 2009 13:25:02 GMT]]></title><description><![CDATA[<p>thx Werner_logoff &amp; knivil !!</p>
<p>richtig is hier eben genau das Problem:) *gg*</p>
<p>auch wenn ich mit</p>
<pre><code>Map[x*mWidth+y] = value
</code></pre>
<p>oder</p>
<pre><code>*Map++= value;
</code></pre>
<p>zugreife, so kommt immer eine von mir nicht gewünschte Zahlenfolge heraus...<br />
und ich kann mir nicht erklären warum....<br />
Wenn ich die länge des 2d arr auf 3 und höhe auf 3 setzt kommt:<br />
`0 1 2</p>
<p>1 2 3</p>
<p>2 3 4`<br />
und leider nicht 1,2,3,4,5,6,7,8,9 als Ausgabe hervor.... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1817840</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1817840</guid><dc:creator><![CDATA[H0lzi]]></dc:creator><pubDate>Fri, 04 Dec 2009 13:25:02 GMT</pubDate></item><item><title><![CDATA[Reply to Semantischer fehler.....woran liegt das? on Fri, 04 Dec 2009 13:46:47 GMT]]></title><description><![CDATA[<p>Hoppla, hab das jz wohl beides falsch aufgefasst....sry:)</p>
<p>knivil schrieb:</p>
<blockquote>
<p>3 + 5 das gleiche wie 5 + 3, aber der Pixel an Stelle (5,3) ist nicht der gleiche wie an (3,5)</p>
</blockquote>
<p>DAS WAR IMMER NOCH MEIN PROBLEM:)<br />
habe die anfrage nur falsch gemacht:)</p>
<p>Danke für die Hilfe Werner_logoff &amp; knivil,nun ist alles klar :xmas2:</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1817853</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1817853</guid><dc:creator><![CDATA[H0lzi]]></dc:creator><pubDate>Fri, 04 Dec 2009 13:46:47 GMT</pubDate></item></channel></rss>