<?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[[Novize][gelöst] cin array Problem !]]></title><description><![CDATA[<p>Hey Leute,</p>
<p>Ich hänge hier vor 'nem Problem was ich leider nicht ausfindig machen kann.</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;windows.h&gt;

using namespace std;

void setField();

char TAB = 9;

int main() {

	int height = 10;
	int width = 20;
	char field[width][height];

	int i = 0;
	int j = 0;
	int k = 0;
	int g = 0;

	for(i = 0; i &lt; height; i++){	
				cout &lt;&lt; TAB &lt;&lt; TAB &lt;&lt; TAB &lt;&lt; TAB;
				for(j = 0; j &lt; width; j++){
					field[i][j] = 'O';
					}
				cout &lt;&lt; endl;
			}

	for(;k &lt; height;){

		system(&quot;cls&quot;);

		for(i = 0; i &lt; height; i++){	
				cout &lt;&lt; TAB &lt;&lt; TAB &lt;&lt; TAB &lt;&lt; TAB;
				for(j = 0; j &lt; width; j++){
					cout &lt;&lt; field[i][j];
					}
				cout &lt;&lt; endl;
			}

		cout &lt;&lt; endl;

		cout &lt;&lt; &quot;field[&quot; &lt;&lt; k &lt;&lt; &quot;][&quot; &lt;&lt; g &lt;&lt; &quot;] = &quot;;
		cin &gt;&gt; field[k][g];
		if(g == width){
			g = 0;
			k++;
		}
		g++;
	}

	/*	for(i = 0; i &lt; height; i++){
			cout &lt;&lt; TAB &lt;&lt; TAB &lt;&lt; TAB &lt;&lt; TAB;
			for(j = 0; j &lt; width; j++){
				field[i][j] = 'x';
				cout &lt;&lt; field[i][j];
				}
			cout &lt;&lt; endl;
		}
	*/

	cout &lt;&lt; endl;
	system(&quot;Pause&quot;);

}
</code></pre>
<p>Habe bis zum array field[0][12] die Eingabe &quot;x&quot; verwendet.<br />
Der Sinn des Programmes soll erstmal sein ein Feld zu zeichnen - wobei das Ganze von oben nach unten gefüllt werden soll.<br />
Problematik liegt ab field[0][10] daran das gleichzeitig field[1][0] mitgefüllt wird - ich habe die Ausgabe des Feldes seperat ausgeben lassen um zu sehen welche array Elemente da ausgegeben werden - wie gewollt wird dort nacheinander alles ausgegeben.</p>
<p>D.h der Fehler muss in der Eingabe der Elementwerte nach dem for loop für die Ausgabe liegen.</p>
<p>Mein Code gibt folgendes Programm aus:</p>
<pre><code>xxxxxxxxxxxxOOOOOOOO
                                xxOOOOOOOOOOOOOOOOOO
                                OOOOOOOOOOOOOOOOOOOO
                                OOOOOOOOOOOOOOOOOOOO
                                OOOOOOOOOOOOOOOOOOOO
                                OOOOOOOOOOOOOOOOOOOO
                                OOOOOOOOOOOOOOOOOOOO
                                OOOOOOOOOOOOOOOOOOOO
                                OOOOOOOOOOOOOOOOOOOO
                                OOOOOOOOOOOOOOOOOOOO

field[0][12] =
</code></pre>
<p>Danke schonmal für jegliche Hilfe !</p>
<p>gruß Charlie</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/321249/novize-gelöst-cin-array-problem</link><generator>RSS for Node</generator><lastBuildDate>Tue, 21 Jul 2026 17:00:08 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/321249.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 29 Oct 2013 18:39:44 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [Novize][gelöst] cin array Problem ! on Tue, 29 Oct 2013 21:14:51 GMT]]></title><description><![CDATA[<p>Hey Leute,</p>
<p>Ich hänge hier vor 'nem Problem was ich leider nicht ausfindig machen kann.</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;windows.h&gt;

using namespace std;

void setField();

char TAB = 9;

int main() {

	int height = 10;
	int width = 20;
	char field[width][height];

	int i = 0;
	int j = 0;
	int k = 0;
	int g = 0;

	for(i = 0; i &lt; height; i++){	
				cout &lt;&lt; TAB &lt;&lt; TAB &lt;&lt; TAB &lt;&lt; TAB;
				for(j = 0; j &lt; width; j++){
					field[i][j] = 'O';
					}
				cout &lt;&lt; endl;
			}

	for(;k &lt; height;){

		system(&quot;cls&quot;);

		for(i = 0; i &lt; height; i++){	
				cout &lt;&lt; TAB &lt;&lt; TAB &lt;&lt; TAB &lt;&lt; TAB;
				for(j = 0; j &lt; width; j++){
					cout &lt;&lt; field[i][j];
					}
				cout &lt;&lt; endl;
			}

		cout &lt;&lt; endl;

		cout &lt;&lt; &quot;field[&quot; &lt;&lt; k &lt;&lt; &quot;][&quot; &lt;&lt; g &lt;&lt; &quot;] = &quot;;
		cin &gt;&gt; field[k][g];
		if(g == width){
			g = 0;
			k++;
		}
		g++;
	}

	/*	for(i = 0; i &lt; height; i++){
			cout &lt;&lt; TAB &lt;&lt; TAB &lt;&lt; TAB &lt;&lt; TAB;
			for(j = 0; j &lt; width; j++){
				field[i][j] = 'x';
				cout &lt;&lt; field[i][j];
				}
			cout &lt;&lt; endl;
		}
	*/

	cout &lt;&lt; endl;
	system(&quot;Pause&quot;);

}
</code></pre>
<p>Habe bis zum array field[0][12] die Eingabe &quot;x&quot; verwendet.<br />
Der Sinn des Programmes soll erstmal sein ein Feld zu zeichnen - wobei das Ganze von oben nach unten gefüllt werden soll.<br />
Problematik liegt ab field[0][10] daran das gleichzeitig field[1][0] mitgefüllt wird - ich habe die Ausgabe des Feldes seperat ausgeben lassen um zu sehen welche array Elemente da ausgegeben werden - wie gewollt wird dort nacheinander alles ausgegeben.</p>
<p>D.h der Fehler muss in der Eingabe der Elementwerte nach dem for loop für die Ausgabe liegen.</p>
<p>Mein Code gibt folgendes Programm aus:</p>
<pre><code>xxxxxxxxxxxxOOOOOOOO
                                xxOOOOOOOOOOOOOOOOOO
                                OOOOOOOOOOOOOOOOOOOO
                                OOOOOOOOOOOOOOOOOOOO
                                OOOOOOOOOOOOOOOOOOOO
                                OOOOOOOOOOOOOOOOOOOO
                                OOOOOOOOOOOOOOOOOOOO
                                OOOOOOOOOOOOOOOOOOOO
                                OOOOOOOOOOOOOOOOOOOO
                                OOOOOOOOOOOOOOOOOOOO

field[0][12] =
</code></pre>
<p>Danke schonmal für jegliche Hilfe !</p>
<p>gruß Charlie</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2363727</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2363727</guid><dc:creator><![CDATA[Falke88]]></dc:creator><pubDate>Tue, 29 Oct 2013 21:14:51 GMT</pubDate></item><item><title><![CDATA[Reply to [Novize][gelöst] cin array Problem ! on Tue, 29 Oct 2013 19:06:16 GMT]]></title><description><![CDATA[<p>Du bist lernresistent. Siehe:<br />
<a href="http://www.c-plusplus.net/forum/p2363728#2363728" rel="nofollow">http://www.c-plusplus.net/forum/p2363728#2363728</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2363731</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2363731</guid><dc:creator><![CDATA[Belli]]></dc:creator><pubDate>Tue, 29 Oct 2013 19:06:16 GMT</pubDate></item><item><title><![CDATA[Reply to [Novize][gelöst] cin array Problem ! on Tue, 29 Oct 2013 19:25:44 GMT]]></title><description><![CDATA[<p>Belli schrieb:</p>
<blockquote>
<p>Du bist lernresistent. Siehe:<br />
<a href="http://www.c-plusplus.net/forum/p2363728#2363728" rel="nofollow">http://www.c-plusplus.net/forum/p2363728#2363728</a></p>
</blockquote>
<p>Wo liegt denn hier das Problem? Wollt' ihr mich auf eine Suchfunktion verweisen? Wenn ja dann bitte ich um ein Stichwort - denn ich habe keine Ahnung wie mein Problem beschrieben werden soll?</p>
<p>gruß Charlie</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2363735</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2363735</guid><dc:creator><![CDATA[Falke88]]></dc:creator><pubDate>Tue, 29 Oct 2013 19:25:44 GMT</pubDate></item><item><title><![CDATA[Reply to [Novize][gelöst] cin array Problem ! on Tue, 29 Oct 2013 19:44:08 GMT]]></title><description><![CDATA[<p>Falke88 schrieb:</p>
<blockquote>
<p>Wo liegt denn hier das Problem?</p>
</blockquote>
<p>Du schreibst:<br />
&quot;Der Sinn des Programmes soll erstmal sein ein Feld zu zeichnen&quot;</p>
<p>Genau darum ging es doch in Deinem von mir zitierten Thread auch schon ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2363739</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2363739</guid><dc:creator><![CDATA[Belli]]></dc:creator><pubDate>Tue, 29 Oct 2013 19:44:08 GMT</pubDate></item><item><title><![CDATA[Reply to [Novize][gelöst] cin array Problem ! on Tue, 29 Oct 2013 20:16:54 GMT]]></title><description><![CDATA[<p>Falke88 schrieb:</p>
<blockquote>
<p>Hey Leute,<br />
Ich hänge hier vor 'nem Problem was ich leider nicht ausfindig machen kann.</p>
</blockquote>
<p>Visual-Studio 2010 komiliert das garnicht erst.</p>
<pre><code>..\feldtest.cpp(15): error C2057: Konstanter Ausdruck erwartet
..\feldtest.cpp(15): error C2466: Zuordnung eines Arrays der konstanten Größe 0 nicht möglich.
..\feldtest.cpp(15): error C2057: Konstanter Ausdruck erwartet
..\feldtest.cpp(15): error C2466: Zuordnung eines Arrays der konstanten Größe 0 nicht möglich.
..\feldtest.cpp(15): error C2087: 'field': Feldindex fehlt
..\feldtest.cpp(15): error C2133: 'field': Unbekannte Größe
</code></pre>
<p>Mit folgender Änderung kompiliert es:</p>
<pre><code>const int height = 10; 
    const int width = 20; 
    char field[width][height];
</code></pre>
<p>Welcher Compiler akzeptiert variable statische Arraygrössen ?</p>
<p>Wenn man nun als erste Eingabe folgendes eingibt</p>
<pre><code>field[0][3] =  123
</code></pre>
<p>ergibt das</p>
<pre><code>123OOOOOOOOOOOOOOOOO
  OOOOOOOOOOOOOOOOOOOO
  OOOOOOOOOOOOOOOOOOOO
  OOOOOOOOOOOOOOOOOOOO
  OOOOOOOOOOOOOOOOOOOO
  OOOOOOOOOOOOOOOOOOOO
  OOOOOOOOOOOOOOOOOOOO
  OOOOOOOOOOOOOOOOOOOO
  OOOOOOOOOOOOOOOOOOOO
  OOOOOOOOOOOOOOOOOOOO
</code></pre>
<p>Soll das so sein ?</p>
<p>Noch ein Hinweis: Felder fangen bei 0 an und Höhe und breite lassen<br />
sich nicht beliebig tauschen.</p>
<p>Somit wäre z.B. sowas falsch!</p>
<pre><code>for(j = 0; j &lt; width; j++){ 
        cout &lt;&lt; field[i][j];
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2363746</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2363746</guid><dc:creator><![CDATA[merano]]></dc:creator><pubDate>Tue, 29 Oct 2013 20:16:54 GMT</pubDate></item><item><title><![CDATA[Reply to [Novize][gelöst] cin array Problem ! on Tue, 29 Oct 2013 20:55:20 GMT]]></title><description><![CDATA[<p>merano schrieb:</p>
<blockquote>
<p>Welcher Compiler akzeptiert variable statische Arraygrössen ?</p>
</blockquote>
<p>Das ist der GCC, wenn man ihn nicht anweist, streng nach ISO-Standard zu handeln. Dann akzeptiert er VLAs wie aus C99.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2363753</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2363753</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Tue, 29 Oct 2013 20:55:20 GMT</pubDate></item><item><title><![CDATA[Reply to [Novize][gelöst] cin array Problem ! on Tue, 29 Oct 2013 21:14:23 GMT]]></title><description><![CDATA[<p>merano schrieb:</p>
<blockquote>
<p>Falke88 schrieb:</p>
<blockquote>
<p>Hey Leute,<br />
Ich hänge hier vor 'nem Problem was ich leider nicht ausfindig machen kann.</p>
</blockquote>
<p>Visual-Studio 2010 komiliert das garnicht erst.</p>
<pre><code>..\feldtest.cpp(15): error C2057: Konstanter Ausdruck erwartet
..\feldtest.cpp(15): error C2466: Zuordnung eines Arrays der konstanten Größe 0 nicht möglich.
..\feldtest.cpp(15): error C2057: Konstanter Ausdruck erwartet
..\feldtest.cpp(15): error C2466: Zuordnung eines Arrays der konstanten Größe 0 nicht möglich.
..\feldtest.cpp(15): error C2087: 'field': Feldindex fehlt
..\feldtest.cpp(15): error C2133: 'field': Unbekannte Größe
</code></pre>
<p>Mit folgender Änderung kompiliert es:</p>
<pre><code>const int height = 10; 
    const int width = 20; 
    char field[width][height];
</code></pre>
<p>Welcher Compiler akzeptiert variable statische Arraygrössen ?</p>
<p>Wenn man nun als erste Eingabe folgendes eingibt</p>
<pre><code>field[0][3] =  123
</code></pre>
<p>ergibt das</p>
<pre><code>123OOOOOOOOOOOOOOOOO
  OOOOOOOOOOOOOOOOOOOO
  OOOOOOOOOOOOOOOOOOOO
  OOOOOOOOOOOOOOOOOOOO
  OOOOOOOOOOOOOOOOOOOO
  OOOOOOOOOOOOOOOOOOOO
  OOOOOOOOOOOOOOOOOOOO
  OOOOOOOOOOOOOOOOOOOO
  OOOOOOOOOOOOOOOOOOOO
  OOOOOOOOOOOOOOOOOOOO
</code></pre>
<p>Soll das so sein ?</p>
<p>Noch ein Hinweis: Felder fangen bei 0 an und Höhe und breite lassen<br />
sich nicht beliebig tauschen.</p>
<p>Somit wäre z.B. sowas falsch!</p>
<pre><code>for(j = 0; j &lt; width; j++){ 
        cout &lt;&lt; field[i][j];
</code></pre>
</blockquote>
<p>Ja das soll so sein:</p>
<pre><code>123456789ABMNOPQRSTK
                                BMNOPQRSTKLOOOOOOOOO
                                LOOOOOOOOOOOOOOOOOOO
                                OOOOOOOOOOOOOOOOOOOO
                                OOOOOOOOOOOOOOOOOOOO
                                OOOOOOOOOOOOOOOOOOOO
                                OOOOOOOOOOOOOOOOOOOO
                                OOOOOOOOOOOOOOOOOOOO
                                OOOOOOOOOOOOOOOOOOOO
                                OOOOOOOOOOOOOOOOOOOO

field[1][9] =
</code></pre>
<p>Das passiert aber wenn du das Ganze weiterführen würdest - siehe die 2. Zeile welche B Simultan übernimmt anstatt bei [1][0] mit &quot;L&quot; weiterzumachen wie es logisch und eigentlich auch gewollt ist.</p>
<p><div class="plugin-markdown"><input type="checkbox" id="checkbox38271" checked="true" /><label for="checkbox38271">umwechseln kann - habe ich wohl irgendwo ausversehen gemacht. Liegt dort der Fehler deiner Meinung nach?</label></div></p>
<p>@ Elli</p>
<p>Mein Thread damals bezog sich auf den ReDraw des Feldes - das habe ich ja mit system(&quot;cls&quot;) gelöst - mit den Threads die Ihr mir gelinkt habt konnte ich leider nichts anfangen.</p>
<p>Edit: Danke @ merano - der Wink mit dem Verwechseln hat den Fehler aufgeworfen - nun klappts !!</p>
<p>gruß Charlie</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2363760</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2363760</guid><dc:creator><![CDATA[Falke88]]></dc:creator><pubDate>Tue, 29 Oct 2013 21:14:23 GMT</pubDate></item><item><title><![CDATA[Reply to [Novize][gelöst] cin array Problem ! on Tue, 29 Oct 2013 22:09:04 GMT]]></title><description><![CDATA[<p>SeppJ schrieb:</p>
<blockquote>
<p>merano schrieb:</p>
<blockquote>
<p>Welcher Compiler akzeptiert variable statische Arraygrössen ?</p>
</blockquote>
<p>Das ist der GCC, wenn man ihn nicht anweist, streng nach ISO-Standard zu handeln. Dann akzeptiert er VLAs wie aus C99.</p>
</blockquote>
<p>Danke für den Hinweis.</p>
<p>Manchmal könnte das ja recht nützlich sein.</p>
<p>The New C: Why Variable Length Arrays<br />
<a href="http://www.drdobbs.com/the-new-cwhy-variable-length-arrays/184401444" rel="nofollow">http://www.drdobbs.com/the-new-cwhy-variable-length-arrays/184401444</a></p>
<p>Kann man Visula-Studio auch dazu &quot;überreden&quot; ?</p>
<p>Fakt ist wohl, das man sich zwischen C und C++ entscheiden sollte.</p>
<blockquote>
<p>There is no support for VLAs in VS. MS suggest you use the C++ mode of the compiler, with std::vector as a replacement for VLAs.</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/2363771</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2363771</guid><dc:creator><![CDATA[merano]]></dc:creator><pubDate>Tue, 29 Oct 2013 22:09:04 GMT</pubDate></item></channel></rss>