<?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[Problem mit einem Array]]></title><description><![CDATA[<p>Hi,</p>
<p>ich hab folgende Funktion geschrieben, die mir eine Transformationsmatrix berechnen soll. Dazu werden zwei Zahlen übergeben, zwei weitere aus globalen Variablen verwendet. Hier der code:</p>
<pre><code>void calcTrans (int x, int y)
	{
		printf(&quot;%d %d\n&quot;,x,y);
		float *dest = new float[9];
		float *tobeinv = new float[9];
		dest[0]=0;		dest[1]=xres/2;	dest[2]=xres;
		dest[3]=yres;	dest[4]=yres/2;	dest[5]=0;
		dest[6]=1;		dest[7]=1;		dest[8]=1;
		tobeinv[0]=0;	tobeinv[1]=x/2;	tobeinv[2]=x;
		tobeinv[3]=y;	tobeinv[4]=y/2;	tobeinv[5]=0;
		tobeinv[6]=1;	tobeinv[7]=1;	tobeinv[8]=1;
		for (int i = 1;i &lt; 10;i++)
		{
			printf(&quot;%d\t&quot;,dest[i-1]);
			if ( i%3 == 0 ) printf(&quot;\n&quot;);
		}
		for (int i = 1;i &lt; 10;i++)
		{
			printf(&quot;%d\t&quot;,tobeinv[i-1]);
			if ( i%3 == 0 ) printf(&quot;\n&quot;);
		}
		trans = mmult(dest,inverse(tobeinv));
		for (int i = 1;i &lt; 10;i++)
		{
			printf(&quot;%d\t&quot;,trans[i-1]);
			if ( i%3 == 0 ) printf(&quot;\n&quot;);
		}
	}
</code></pre>
<p>Die for-Schleifen dienen der Ausgabe. Mein Problem ist jetzt, dass ich da immer 0 (für jedes Arrayelement) bekomme.<br />
Ich fürchte, dass das ein Problem ist, das schon 1000 mal in den FAQs beantwortet wirde, aber entweder bin ich im Moment zu verbohrt, oder einfach zu dämlich da eine Lösung zu finden. An der nicht benutzten SuFu liegts nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/195214/problem-mit-einem-array</link><generator>RSS for Node</generator><lastBuildDate>Tue, 29 Sep 2026 21:13:12 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/195214.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 15 Oct 2007 13:44:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem mit einem Array on Mon, 15 Oct 2007 13:44:10 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>ich hab folgende Funktion geschrieben, die mir eine Transformationsmatrix berechnen soll. Dazu werden zwei Zahlen übergeben, zwei weitere aus globalen Variablen verwendet. Hier der code:</p>
<pre><code>void calcTrans (int x, int y)
	{
		printf(&quot;%d %d\n&quot;,x,y);
		float *dest = new float[9];
		float *tobeinv = new float[9];
		dest[0]=0;		dest[1]=xres/2;	dest[2]=xres;
		dest[3]=yres;	dest[4]=yres/2;	dest[5]=0;
		dest[6]=1;		dest[7]=1;		dest[8]=1;
		tobeinv[0]=0;	tobeinv[1]=x/2;	tobeinv[2]=x;
		tobeinv[3]=y;	tobeinv[4]=y/2;	tobeinv[5]=0;
		tobeinv[6]=1;	tobeinv[7]=1;	tobeinv[8]=1;
		for (int i = 1;i &lt; 10;i++)
		{
			printf(&quot;%d\t&quot;,dest[i-1]);
			if ( i%3 == 0 ) printf(&quot;\n&quot;);
		}
		for (int i = 1;i &lt; 10;i++)
		{
			printf(&quot;%d\t&quot;,tobeinv[i-1]);
			if ( i%3 == 0 ) printf(&quot;\n&quot;);
		}
		trans = mmult(dest,inverse(tobeinv));
		for (int i = 1;i &lt; 10;i++)
		{
			printf(&quot;%d\t&quot;,trans[i-1]);
			if ( i%3 == 0 ) printf(&quot;\n&quot;);
		}
	}
</code></pre>
<p>Die for-Schleifen dienen der Ausgabe. Mein Problem ist jetzt, dass ich da immer 0 (für jedes Arrayelement) bekomme.<br />
Ich fürchte, dass das ein Problem ist, das schon 1000 mal in den FAQs beantwortet wirde, aber entweder bin ich im Moment zu verbohrt, oder einfach zu dämlich da eine Lösung zu finden. An der nicht benutzten SuFu liegts nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1385627</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1385627</guid><dc:creator><![CDATA[ratz159]]></dc:creator><pubDate>Mon, 15 Oct 2007 13:44:10 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit einem Array on Mon, 15 Oct 2007 13:49:58 GMT]]></title><description><![CDATA[<p>Wenn du schon mit printf() arbeitest, dann nimm bitte auch die richtigen Format-Kennungen - double (und float) Werte werden mit %e/%E (wissenschaftlich), %f (&quot;normal&quot;) oder %g/%G (je nach Ausgabelänge) ausgegeben.</p>
<p>(aber nachdem du im C++ Board gelandet bist - nimm lieber cout für die Ausgaben, das erkennt selber den richtigen Typ)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1385642</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1385642</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 15 Oct 2007 13:49:58 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit einem Array on Mon, 15 Oct 2007 13:54:23 GMT]]></title><description><![CDATA[<p>Bei welchem Array erhältst du immer nur Nullen?<br />
Und von welchen Datentyp sind die globalen Variablen 'xres' und 'yres' (globale Variablen sind böse!)<br />
Außerdem: was ist 'trans' und sind die Funktionen 'mmult' und 'inverse' von dir selbst erstellt?</p>
<p>Und du solltest den Speicher wieder am Ende freigeben bzw. gleich ein lokales Array benutzen.<br />
In C++ solltest du außerdem 'cout' benutzen...</p>
<blockquote>
<p>An der nicht benutzten SuFu liegts nicht.</p>
</blockquote>
<p>Super Spruch <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/1385648</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1385648</guid><dc:creator><![CDATA[Th]]></dc:creator><pubDate>Mon, 15 Oct 2007 13:54:23 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit einem Array on Mon, 15 Oct 2007 14:05:26 GMT]]></title><description><![CDATA[<p>Danke CStoll! dachte nicht, dass es sogar ein soooo dummer Fehler ist.</p>
<pre><code>float zahl=10.0;
printf(&quot;%d&quot;,zahl); // gibt 0 aus
printf(&quot;%f&quot;,zahl); // gibt 10.000000 aus
</code></pre>
<p>Bei den Ausgaben handelt es sich &quot;nur&quot; um Debugausgaben. Da ich vor C++ Java programmiert hab, ging mir das printf schneller von der Hand als cout - werd mir aber nach dieser Erfahrung bei jedem printf auf die Finger klopfen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1385661</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1385661</guid><dc:creator><![CDATA[ratz159]]></dc:creator><pubDate>Mon, 15 Oct 2007 14:05:26 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit einem Array on Mon, 15 Oct 2007 14:18:25 GMT]]></title><description><![CDATA[<p>Alles eine Frage der Gewohnheit - ich finde <code>cout&lt;&lt;zahl;</code> eleganter als <code>printf(&quot;%f&quot;,zahl);</code> . (und vor allem muß man sich bei cout nicht mehr damit beschäftigen, ob man nun die korrekte Formatkennung angegeben hat)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1385676</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1385676</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 15 Oct 2007 14:18:25 GMT</pubDate></item></channel></rss>