<?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[mehrdimensionale statische Felder]]></title><description><![CDATA[<p>Hi,<br />
ich brauch im meinem Programm ein mehrdimensionales Feld, das seinen Wert nicht zwischen Funktionsaufrufen verliert. Ich habe es mit</p>
<pre><code class="language-cpp">static BYTE byZustSteine[ANZSPALTEN][MAXSTEINE];
</code></pre>
<p>probiert, aber das funktioniert nicht.</p>
<p>Gruß,<br />
Held</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/182346/mehrdimensionale-statische-felder</link><generator>RSS for Node</generator><lastBuildDate>Tue, 22 Sep 2026 17:34:54 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/182346.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 23 May 2007 21:29:55 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to mehrdimensionale statische Felder on Wed, 23 May 2007 21:29:55 GMT]]></title><description><![CDATA[<p>Hi,<br />
ich brauch im meinem Programm ein mehrdimensionales Feld, das seinen Wert nicht zwischen Funktionsaufrufen verliert. Ich habe es mit</p>
<pre><code class="language-cpp">static BYTE byZustSteine[ANZSPALTEN][MAXSTEINE];
</code></pre>
<p>probiert, aber das funktioniert nicht.</p>
<p>Gruß,<br />
Held</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1291113</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1291113</guid><dc:creator><![CDATA[Held vom Erdbeerfeld]]></dc:creator><pubDate>Wed, 23 May 2007 21:29:55 GMT</pubDate></item><item><title><![CDATA[Reply to mehrdimensionale statische Felder on Wed, 23 May 2007 21:45:45 GMT]]></title><description><![CDATA[<p>wo hast du das hingeschrieben? ANZSPALTEN MAXSTEINE sind konstanten?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1291120</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1291120</guid><dc:creator><![CDATA[und...]]></dc:creator><pubDate>Wed, 23 May 2007 21:45:45 GMT</pubDate></item><item><title><![CDATA[Reply to mehrdimensionale statische Felder on Thu, 24 May 2007 08:28:27 GMT]]></title><description><![CDATA[<p>Sorry, war vielleicht ein bisschen kurz. ANZSPALTEN und MAXSTEINE hab ich als Makros definiert.</p>
<p>Die Deklaration befindet sich in der Callback Procedure für diverse Childfenster.</p>
<pre><code class="language-cpp">LRESULT CALLBACK SpalteWndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
    ...
    static BYTE byZustSteine[ANZSPALTEN][MAXSTEINE];
    ...
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1291245</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1291245</guid><dc:creator><![CDATA[Held vom Erdbeerfeld]]></dc:creator><pubDate>Thu, 24 May 2007 08:28:27 GMT</pubDate></item><item><title><![CDATA[Reply to mehrdimensionale statische Felder on Thu, 24 May 2007 08:47:54 GMT]]></title><description><![CDATA[<p>&quot;funktioniert nicht&quot; ist keine ausreichende Fehlerbeschreibung. Kriegst du eine Fehlermeldung? Wenn ja, wie lautet diese? Außerdem wäre es mal schön deine Markodefinitionen zu sehen. Ich würde dir allerdings sowieso in C++ zu Konstanten raten:</p>
<pre><code class="language-cpp">unsigned int const ANZSPALTEN = ...;
unsigned int const MAXSTEINE = ...;
</code></pre>
<p>Greetz</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1291261</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1291261</guid><dc:creator><![CDATA[Vellas]]></dc:creator><pubDate>Thu, 24 May 2007 08:47:54 GMT</pubDate></item><item><title><![CDATA[Reply to mehrdimensionale statische Felder on Thu, 24 May 2007 08:58:10 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>gern gemachter Fehler:</p>
<p>Semikolon hinter der define Anweisung. Benutze lieber const-Variablen (was für eine Wort)</p>
<p>chrische</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1291268</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1291268</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Thu, 24 May 2007 08:58:10 GMT</pubDate></item><item><title><![CDATA[Reply to mehrdimensionale statische Felder on Thu, 24 May 2007 09:11:07 GMT]]></title><description><![CDATA[<p>Neuer Versuch:</p>
<pre><code class="language-cpp">#define MAXSTEINE 6
#define ANZSPALTEN 7
</code></pre>
<p>Ich kann das Programm fehlerlos kompilieren (GNU GCC Compiler), abgesehen von ein paar Warnungen, die auf nicht verwendete Parameter hinweisen. Wenn ich das Feld ausgebe</p>
<pre><code class="language-cpp">for(int i=0;i&lt;ANZSPALTEN;i++)
        {
            cout &lt;&lt; endl;
            for(int j=0;j&lt;MAXSTEINE;j++)
            {
                cout &lt;&lt; (int)byZustSteine[i][j];
            }
        }
</code></pre>
<p>sind nach jedem Funktionsaufruf (Mausklick) die alten Werte weg und es wir nur der neue ausgegeben.</p>
<p>Allerdings ist mir auch gerade der Fehler aufgefallen. Ich wollte nach dem deklarieren das Feld mit Nullen füllen, hab aber dummerweise dadurch immer wieder alles mit Nullen überschrieben. Schon dumm wenn man dumm ist.</p>
<p>Das führt auch gleich zu meiner nächsten Frage, gibt es eine Möglichkeit das Feld beim <strong>ersten</strong> Aufruf zu füllen und dann die neuen Werte nicht mehr zu überschreiben. Ich habs bisher so gemacht</p>
<pre><code class="language-cpp">for(int i=0;i&lt;ANZSPALTEN;i++)
    {
        for(int j=0;j&lt;MAXSTEINE;j++)
        {
            byZustSteine[i][j]=0;
        }
    }
</code></pre>
<p>was aber offensichtlich nicht Funktioniert hat.</p>
<p>Held</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1291273</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1291273</guid><dc:creator><![CDATA[Held vom Erdbeerfeld]]></dc:creator><pubDate>Thu, 24 May 2007 09:11:07 GMT</pubDate></item><item><title><![CDATA[Reply to mehrdimensionale statische Felder on Thu, 24 May 2007 09:17:51 GMT]]></title><description><![CDATA[<p>static-Werte werden normal beim ersten Mal angelegt und initialisiert, wenn das Programm über ihre Definition drüberläuft. Deine Initialisierungsschleife wird aber bei jedem Funktionsaufruf abgearbeitet - und setzt das Array wieder auf Anfang zurück. In deinem Fall ist die Lösung fast schon trivial - nimm eine Initialisierungsliste <code>static BYTE byZustSteine[ANZSPALTEN][MAXSTEINE]={{0}};</code> . Wenn die Erstbelegung des Feldes etwas aufwendiger ist, hilft folgendes:</p>
<pre><code class="language-cpp">static BYTE byZustSteine[ANZSPALTEN][MAXSTEINE];
static bool isready=false;
if(!isready)
{
  //fülle dein Array
  isready=true;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1291277</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1291277</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Thu, 24 May 2007 09:17:51 GMT</pubDate></item><item><title><![CDATA[Reply to mehrdimensionale statische Felder on Thu, 24 May 2007 09:21:51 GMT]]></title><description><![CDATA[<p>Danke,<br />
es ist schön, wenn es auch einfache Lösungen gibt.</p>
<p>Held</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1291283</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1291283</guid><dc:creator><![CDATA[Held vom Erdbeerfeld]]></dc:creator><pubDate>Thu, 24 May 2007 09:21:51 GMT</pubDate></item><item><title><![CDATA[Reply to mehrdimensionale statische Felder on Thu, 24 May 2007 12:31:52 GMT]]></title><description><![CDATA[<p>Held vom Erdbeerfeld schrieb:</p>
<blockquote>
<p>Neuer Versuch:</p>
<pre><code class="language-cpp">#define MAXSTEINE 6
#define ANZSPALTEN 7
</code></pre>
</blockquote>
<p>versuch fehlgeschlagen, bitte noch einmal.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1291384</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1291384</guid><dc:creator><![CDATA[knarz]]></dc:creator><pubDate>Thu, 24 May 2007 12:31:52 GMT</pubDate></item><item><title><![CDATA[Reply to mehrdimensionale statische Felder on Thu, 24 May 2007 15:14:59 GMT]]></title><description><![CDATA[<p>Sorry, aber das versteh ich jetzt nicht so ganz. Das Programm lässt sich fehlerfrei kompilieren und macht das was ich will.<br />
Wenn du Verbesserungsvorschläge hast: Ich lerne gerne dazu.<br />
Wenn du meinst, dass das keine const-Variablen sind: das ist mir durchaus bewusst und ich werde das bei Gelegenheit ausbessern.</p>
<p>Held</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1291489</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1291489</guid><dc:creator><![CDATA[Held vom Erdbeerfeld]]></dc:creator><pubDate>Thu, 24 May 2007 15:14:59 GMT</pubDate></item></channel></rss>