<?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[while-schleife]]></title><description><![CDATA[<p>Hallo Leute,<br />
ich habe ein Problem in meinem Code. Ich möchte ein Tic-Tac-Toe spiel in einer Konsole Programmieren. Jetzt habe ich das ganze Programmiert, und wollte ihm hetzt sagen (mit einer while Schleife), mache das so lang, bis cFeld1,cFeld2,cFeld3 != 'X' ('O') ist.<br />
Wenn ich das so machte, :</p>
<pre><code>while(cFeld1,cFeld2,cFeld3 != 'X')
{}
</code></pre>
<p>so allerdings nicht mehr <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>
<pre><code>while(cFeld1,cFeld2,cFeld3 != 'X' || cFeld4,cFeld5,cFeld6 != 'X')
{}
</code></pre>
<p>Könnt ihr mir bitte helfen?<br />
Danke im Vorhinein.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/279897/while-schleife</link><generator>RSS for Node</generator><lastBuildDate>Mon, 24 Aug 2026 08:05:47 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/279897.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 05 Jan 2011 18:31:40 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to while-schleife on Wed, 05 Jan 2011 18:31:40 GMT]]></title><description><![CDATA[<p>Hallo Leute,<br />
ich habe ein Problem in meinem Code. Ich möchte ein Tic-Tac-Toe spiel in einer Konsole Programmieren. Jetzt habe ich das ganze Programmiert, und wollte ihm hetzt sagen (mit einer while Schleife), mache das so lang, bis cFeld1,cFeld2,cFeld3 != 'X' ('O') ist.<br />
Wenn ich das so machte, :</p>
<pre><code>while(cFeld1,cFeld2,cFeld3 != 'X')
{}
</code></pre>
<p>so allerdings nicht mehr <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>
<pre><code>while(cFeld1,cFeld2,cFeld3 != 'X' || cFeld4,cFeld5,cFeld6 != 'X')
{}
</code></pre>
<p>Könnt ihr mir bitte helfen?<br />
Danke im Vorhinein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2002849</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2002849</guid><dc:creator><![CDATA[Gastschorry]]></dc:creator><pubDate>Wed, 05 Jan 2011 18:31:40 GMT</pubDate></item><item><title><![CDATA[Reply to while-schleife on Wed, 05 Jan 2011 18:40:00 GMT]]></title><description><![CDATA[<p>verwende &amp;&amp; anstatt ||</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2002853</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2002853</guid><dc:creator><![CDATA[alogheo]]></dc:creator><pubDate>Wed, 05 Jan 2011 18:40:00 GMT</pubDate></item><item><title><![CDATA[Reply to while-schleife on Wed, 05 Jan 2011 18:44:21 GMT]]></title><description><![CDATA[<p>Wenn du erwartest, dass alle drei mit Komma getrennten Felder verglichen werden, muss ich dich enttäuschen. Du musst jedes Feld einzeln vergleichen und mit &amp;&amp; (oder ||) verknüpfen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2002856</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2002856</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Wed, 05 Jan 2011 18:44:21 GMT</pubDate></item><item><title><![CDATA[Reply to while-schleife on Wed, 05 Jan 2011 18:59:09 GMT]]></title><description><![CDATA[<p>Das hab ich auch schon probiert... ist das gleiche ergebnis wie mit komma.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2002863</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2002863</guid><dc:creator><![CDATA[Gastschorry]]></dc:creator><pubDate>Wed, 05 Jan 2011 18:59:09 GMT</pubDate></item><item><title><![CDATA[Reply to while-schleife on Wed, 05 Jan 2011 19:04:25 GMT]]></title><description><![CDATA[<p>Ok mit &amp;&amp; hab ich es auch gerade versucht, und hab das Ergebnis herausbekommen, was ich vermutet hatte, und zwar müssen dann Feld 1,2,3,4,5 und 6 den Wert 'X' haben...<br />
P.S. das mit dem Komma ist fast das gleiche wie &amp;&amp;</p>
<p>z.B. ist das das gleiche :</p>
<pre><code>while(cFeld1,cFeld2 != 'X')
//und
while(cFeld1 &amp;&amp; cFeld2 != 'X')
</code></pre>
<p>Ich Schreib ma eben den kompletten Quelltext, villeicht versteht ihr mich dann. :</p>
<pre><code>/*Tic-Tac-Toe*/
#include &lt;iostream&gt;
#include &lt;conio.h&gt;

using namespace std;

int main()
{
	char cFeld1 = '1',
			 cFeld2 = '2',
			 cFeld3 = '3',
			 cFeld4 = '4',
			 cFeld5 = '5',
			 cFeld6 = '6',
			 cFeld7 = '7',
			 cFeld8 = '8',
			 cFeld9 = '9';

		char cPlayer1 = 'X',
			 cPlayer2 = 'O';

		int iEingabe = 0 ;

	while(cFeld1,cFeld2,cFeld3 != 'X' &amp;&amp; cFeld4,cFeld5,cFeld6 != 'X' )		//while(cFeld1,cFeld2,cFeld3 != 'X' || cFeld4,cFeld5,cFeld6 != 'X' || cFeld7,cFeld8,cFeld9 != 'X' || cFeld1,cFeld4,cFeld7 != 'X' || cFeld2,cFeld5,cFeld8 != 'X' || cFeld3,cFeld6,cFeld9 != 'X'|| cFeld1,cFeld5,cFeld9 != 'X' || cFeld3,cFeld5,cFeld7 != 'X'				 ||					cFeld1,cFeld2,cFeld3 != 'O' || cFeld4,cFeld5,cFeld6 != 'O' || cFeld7,cFeld8,cFeld9 != 'O' || cFeld1,cFeld4,cFeld7 != 'O' || cFeld2,cFeld5,cFeld8 != 'O' || cFeld3,cFeld6,cFeld9 != 'O'|| cFeld1,cFeld5,cFeld9 != 'O' || cFeld3,cFeld5,cFeld7 != 'O' )
	{

		/* Zu Player 1 */
		do
		{
			iEingabe = 0 ;

			cout &lt;&lt; cFeld1 &lt;&lt; &quot; | &quot; &lt;&lt; cFeld2 &lt;&lt; &quot; | &quot; &lt;&lt; cFeld3 &lt;&lt; endl
				 &lt;&lt;          &quot;--+-&quot; &lt;&lt;          &quot;--+--&quot; &lt;&lt; endl
				 &lt;&lt; cFeld4 &lt;&lt; &quot; | &quot; &lt;&lt; cFeld5 &lt;&lt; &quot; | &quot; &lt;&lt; cFeld6 &lt;&lt; endl
				 &lt;&lt;          &quot;--+-&quot; &lt;&lt;          &quot;--+--&quot; &lt;&lt; endl
				 &lt;&lt; cFeld7 &lt;&lt; &quot; | &quot; &lt;&lt; cFeld8 &lt;&lt; &quot; | &quot; &lt;&lt; cFeld9 &lt;&lt; endl
				 &lt;&lt; endl
				 &lt;&lt; &quot;Player 1 ist an der Reihe.&quot; &lt;&lt; endl;

		cin &gt;&gt; iEingabe;
			//	iEingabe = getch();
			system(&quot;cls&quot;);
		}
		while(iEingabe &gt; 9 || iEingabe &lt; 1 );

		switch(iEingabe)
		{
			case 1:
				cFeld1 = cPlayer1;
				break;

			case 2:
				cFeld2 = cPlayer1;
				break;

			case 3:
				cFeld3 = cPlayer1;
				break;

			case 4:
				cFeld4 = cPlayer1;
				break;

			case 5:
				cFeld5 = cPlayer1;
				break;

			case 6:
				cFeld6 = cPlayer1;
				break;

			case 7:
				cFeld7 = cPlayer1;
				break;

			case 8:
				cFeld8 = cPlayer1;
				break;

			case 9:
				cFeld9 = cPlayer1;
				break;
		}

		/* Zu Player 2 */
		do
		{
			iEingabe = 0 ;

			cout &lt;&lt; cFeld1 &lt;&lt; &quot; | &quot; &lt;&lt; cFeld2 &lt;&lt; &quot; | &quot; &lt;&lt; cFeld3 &lt;&lt; endl
				 &lt;&lt;          &quot;--+-&quot; &lt;&lt;          &quot;--+--&quot; &lt;&lt; endl
				 &lt;&lt; cFeld4 &lt;&lt; &quot; | &quot; &lt;&lt; cFeld5 &lt;&lt; &quot; | &quot; &lt;&lt; cFeld6 &lt;&lt; endl
				 &lt;&lt;          &quot;--+-&quot; &lt;&lt;          &quot;--+--&quot; &lt;&lt; endl
				 &lt;&lt; cFeld7 &lt;&lt; &quot; | &quot; &lt;&lt; cFeld8 &lt;&lt; &quot; | &quot; &lt;&lt; cFeld9 &lt;&lt; endl
				 &lt;&lt; endl
				 &lt;&lt; &quot;Player 2 ist an der Reihe.&quot; &lt;&lt; endl;

			cin &gt;&gt; iEingabe;
			//iEingabe = getch();
			system(&quot;cls&quot;);
		}
		while(iEingabe &gt; 9 || iEingabe &lt; 1 );

		switch(iEingabe)
		{
			case 1:
				cFeld1 = cPlayer2;
				break;

			case 2:
				cFeld2 = cPlayer2;
				break;

			case 3:
				cFeld3 = cPlayer2;
				break;

			case 4:
				cFeld4 = cPlayer2;
				break;

			case 5:
				cFeld5 = cPlayer2;
				break;

			case 6:
				cFeld6 = cPlayer2;
				break;

			case 7:
				cFeld7 = cPlayer2;
				break;

			case 8:
				cFeld8 = cPlayer2;
				break;

			case 9:
				cFeld9 = cPlayer2;
				break;
		}

	}
	system(&quot;pause&gt;nul&quot;);
	return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2002864</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2002864</guid><dc:creator><![CDATA[Gastschorry]]></dc:creator><pubDate>Wed, 05 Jan 2011 19:04:25 GMT</pubDate></item><item><title><![CDATA[Reply to while-schleife on Wed, 05 Jan 2011 19:13:12 GMT]]></title><description><![CDATA[<pre><code>while(cFeld1,cFeld2 != 'X') 
//und 
while(cFeld1 &amp;&amp; cFeld2 != 'X')
</code></pre>
<p>Geht so nicht.</p>
<p>Ist zwar jetzt nur Fleißarbeit, aber es geht so:</p>
<pre><code class="language-cpp">while(cFeld != 'X' &amp;&amp; cFeld2 != 'X')
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2002868</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2002868</guid><dc:creator><![CDATA[Cybertec]]></dc:creator><pubDate>Wed, 05 Jan 2011 19:13:12 GMT</pubDate></item><item><title><![CDATA[Reply to while-schleife on Wed, 05 Jan 2011 19:16:31 GMT]]></title><description><![CDATA[<p>Cybertec schrieb:</p>
<blockquote>
<pre><code>while(cFeld1,cFeld2 != 'X') 
//und 
while(cFeld1 &amp;&amp; cFeld2 != 'X')
</code></pre>
<p>Geht so nicht.</p>
<p>Ist zwar jetzt nur Fleißarbeit, aber es geht so:</p>
<pre><code class="language-cpp">while(cFeld != 'X' &amp;&amp; cFeld2 != 'X')
</code></pre>
</blockquote>
<p>Nichts anderes wurde dir oben gesagt: Du sollst &amp;&amp; verwenden und Komma funktioniert nicht, weil du jeden Wert einzeln prüfen musst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2002870</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2002870</guid><dc:creator><![CDATA[HighLigerBiMBam]]></dc:creator><pubDate>Wed, 05 Jan 2011 19:16:31 GMT</pubDate></item><item><title><![CDATA[Reply to while-schleife on Wed, 05 Jan 2011 19:25:31 GMT]]></title><description><![CDATA[<p>ja meinte (↓) ich ja sorry</p>
<pre><code>while(cFeld1 != 'X' &amp;&amp; cFeld2 != 'X')
</code></pre>
<p>okay... aber warum geht es trozdem nicht wenn ich es so mache???</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2002879</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2002879</guid><dc:creator><![CDATA[Gastschorry]]></dc:creator><pubDate>Wed, 05 Jan 2011 19:25:31 GMT</pubDate></item><item><title><![CDATA[Reply to while-schleife on Wed, 05 Jan 2011 19:41:42 GMT]]></title><description><![CDATA[<p>&quot;Es funktioniert nicht&quot; ist keine passende Fehlerbeschreibung.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2002884</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2002884</guid><dc:creator><![CDATA[knivil]]></dc:creator><pubDate>Wed, 05 Jan 2011 19:41:42 GMT</pubDate></item><item><title><![CDATA[Reply to while-schleife on Wed, 05 Jan 2011 19:43:39 GMT]]></title><description><![CDATA[<p>Das heisst was?<br />
Was muss ich dann machen das es geht?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2002885</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2002885</guid><dc:creator><![CDATA[Gastschorry]]></dc:creator><pubDate>Wed, 05 Jan 2011 19:43:39 GMT</pubDate></item><item><title><![CDATA[Reply to while-schleife on Wed, 05 Jan 2011 19:46:02 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">while((cFeld1 != cPlayer1 || cFeld2 != cPlayer1 || cFeld3 != cPlayer1) &amp;&amp; ....)
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2002887</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2002887</guid><dc:creator><![CDATA[HighLigerBiMBam]]></dc:creator><pubDate>Wed, 05 Jan 2011 19:46:02 GMT</pubDate></item><item><title><![CDATA[Reply to while-schleife on Wed, 05 Jan 2011 19:51:07 GMT]]></title><description><![CDATA[<p>Mir ist gerade noch etwas aufgefallen:<br />
Wenn ich schreibe :</p>
<pre><code>while(cFeld1 != 'X' &amp;&amp; cFeld2 != 'X' &amp;&amp; cFeld3 != 'X' || cFeld4 != 'X' &amp;&amp; cFeld5 != 'X' &amp;&amp; cFeld6 != 'X' )
</code></pre>
<p>dann beendet er nur, wenn entweder in feld 1,2, und 3 ein 'x' ist UND in 4,5 und 6 kein 'O' oder wenn in 4,5 oder 6 ein 'X' ist aber KEINS in 1,2 oder 3 ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2002889</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2002889</guid><dc:creator><![CDATA[Gastschorry]]></dc:creator><pubDate>Wed, 05 Jan 2011 19:51:07 GMT</pubDate></item><item><title><![CDATA[Reply to while-schleife on Wed, 05 Jan 2011 19:54:24 GMT]]></title><description><![CDATA[<p>Ja aber bei der Schreibweise, beendet er dann ja schon, wenn bei 1, 2 ODER 3 ein 'X' ist... der soll ja erst beenden, wenn bei 1,2 UND 3 ein 'X' ist...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2002890</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2002890</guid><dc:creator><![CDATA[Gastschorry]]></dc:creator><pubDate>Wed, 05 Jan 2011 19:54:24 GMT</pubDate></item><item><title><![CDATA[Reply to while-schleife on Wed, 05 Jan 2011 20:07:00 GMT]]></title><description><![CDATA[<p>Meins ist richtig. Ich versuche es dir zu erklären:</p>
<p>Wenn nirgends ein x steht, dann ist feld1 != 'X' -&gt; true<br />
folglich steht im while(true || true || true) -&gt; true das programm läuft weiter</p>
<p>nehmen wir an feld 1 ist nun X dann ist feld1 != 'X' -&gt; false<br />
folglich steht im while(false||true||true) -&gt; true das programm läuft weiter</p>
<p>nehmen wir an feld 1 und feld 2 ist nun X dann ist feld1 != 'X' -&gt; false<br />
folglich steht im while(false||false||true) -&gt; true das programm läuft weiter</p>
<p>wenn jetzt feld 1, feld 2 und feld 3 = 'X' sind, dann sind sie alle false<br />
folglich steht im while(false || false || false) -&gt; false schleife endet</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2002900</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2002900</guid><dc:creator><![CDATA[HighLigerBiMBam]]></dc:creator><pubDate>Wed, 05 Jan 2011 20:07:00 GMT</pubDate></item><item><title><![CDATA[Reply to while-schleife on Wed, 05 Jan 2011 20:12:12 GMT]]></title><description><![CDATA[<p>Ah stimmt...<br />
das erscheint mir logisch... danke ich werds ausprbieren, und wenn es nicht funkt. werdich mich wieder melden...<br />
Danke aber erst mal...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2002904</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2002904</guid><dc:creator><![CDATA[Gastschorry]]></dc:creator><pubDate>Wed, 05 Jan 2011 20:12:12 GMT</pubDate></item><item><title><![CDATA[Reply to while-schleife on Wed, 05 Jan 2011 20:18:57 GMT]]></title><description><![CDATA[<p>Ich habe mir dran auch gerade meinen Kopf zerbrochen bis ich es mir mal aufschrieb...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2002907</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2002907</guid><dc:creator><![CDATA[HighLigerBiMBam]]></dc:creator><pubDate>Wed, 05 Jan 2011 20:18:57 GMT</pubDate></item><item><title><![CDATA[Reply to while-schleife on Wed, 05 Jan 2011 20:19:54 GMT]]></title><description><![CDATA[<p>Ok muss leider sagen hat nicht funzt...<br />
weis nicht woran es liegt... bin zu doof : D<br />
naja ich werde mal meinen Freund / Kollegen fragen... der macht das auch beruflich... der kann mir bestimmt helfen, weiss hallt nur nicht wann ich den wieder sehe...<br />
naja ich bedanke mich trozdem...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2002909</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2002909</guid><dc:creator><![CDATA[Gastschorry]]></dc:creator><pubDate>Wed, 05 Jan 2011 20:19:54 GMT</pubDate></item><item><title><![CDATA[Reply to while-schleife on Wed, 05 Jan 2011 20:23:30 GMT]]></title><description><![CDATA[<p>Bei mir gehts... Bitte bachte die Klammern und das UND</p>
<p>while((cFeld1 != cPlayer1 || cFeld2 != cPlayer1 || cFeld3 != cPlayer1) &amp;&amp; (cFeld4 != cPlayer1 || cFeld5 != cPlayer1 || cFeld6 != cPlayer1))</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2002910</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2002910</guid><dc:creator><![CDATA[HighLigerBiMBam]]></dc:creator><pubDate>Wed, 05 Jan 2011 20:23:30 GMT</pubDate></item><item><title><![CDATA[Reply to while-schleife on Wed, 05 Jan 2011 20:29:30 GMT]]></title><description><![CDATA[<p>Ja hab ich.. aber weiss nicht woran es liegt... naja egal</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2002912</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2002912</guid><dc:creator><![CDATA[Gastschorry]]></dc:creator><pubDate>Wed, 05 Jan 2011 20:29:30 GMT</pubDate></item><item><title><![CDATA[Reply to while-schleife on Wed, 05 Jan 2011 20:34:26 GMT]]></title><description><![CDATA[<p>WOW... es geht...<br />
als ich es von dir copy hatte gings DANKEEEE<br />
ich denke ich hatte mich vertippt oder so...<br />
wirklich cool : D so schnell und es funzt... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /> danke <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/2002914</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2002914</guid><dc:creator><![CDATA[Gastschorry]]></dc:creator><pubDate>Wed, 05 Jan 2011 20:34:26 GMT</pubDate></item><item><title><![CDATA[Reply to while-schleife on Wed, 05 Jan 2011 21:22:30 GMT]]></title><description><![CDATA[<p>Falls ihr es mal sehen wollt... ich habe es bis auf ein paar kleinigkeiten fertig.<br />
Aber hier ist der Code:</p>
<pre><code>/*Tic-Tac-Toe*/
#include &lt;iostream&gt;
#include &lt;conio.h&gt;

using namespace std;

int main()
{
	char cFeld1 = '1',
			 cFeld2 = '2',
			 cFeld3 = '3',
			 cFeld4 = '4',
			 cFeld5 = '5',
			 cFeld6 = '6',
			 cFeld7 = '7',
			 cFeld8 = '8',
			 cFeld9 = '9';

		char cPlayer1 = 'X',
			 cPlayer2 = 'O';

		char cjn;

		int iEingabe = 0 ;

		/* Anleitung */
		cout &lt;&lt; &quot;Bitte gebe die Zahl des Feldes ein, und bestätige mit der [Enter]-Taste!&quot;;
		system(&quot;pause&gt;nul&quot;);

	do
	{

		/* Zu Player 1 */
		wieder1:
		system(&quot;cls&quot;);
		do
		{
			iEingabe = 0 ;

			cout &lt;&lt; cFeld1 &lt;&lt; &quot; | &quot; &lt;&lt; cFeld2 &lt;&lt; &quot; | &quot; &lt;&lt; cFeld3 &lt;&lt; endl
				 &lt;&lt;          &quot;--+-&quot; &lt;&lt;          &quot;--+--&quot; &lt;&lt; endl
				 &lt;&lt; cFeld4 &lt;&lt; &quot; | &quot; &lt;&lt; cFeld5 &lt;&lt; &quot; | &quot; &lt;&lt; cFeld6 &lt;&lt; endl
				 &lt;&lt;          &quot;--+-&quot; &lt;&lt;          &quot;--+--&quot; &lt;&lt; endl
				 &lt;&lt; cFeld7 &lt;&lt; &quot; | &quot; &lt;&lt; cFeld8 &lt;&lt; &quot; | &quot; &lt;&lt; cFeld9 &lt;&lt; endl
				 &lt;&lt; endl
				 &lt;&lt; &quot;Player 1 ist an der Reihe.&quot; &lt;&lt; endl;

		cin &gt;&gt; iEingabe;
			//	iEingabe = getch();
			system(&quot;cls&quot;);
		}
		while(iEingabe &gt; 9 || iEingabe &lt; 1 );

		switch(iEingabe)
		{
			case 1:
				if(cFeld1 == '1')
				{
					cFeld1 = cPlayer1;
				}
				else
				{
					cout &lt;&lt; &quot;Feld schon belegt!&quot;;
					system(&quot;pause&gt;nul&quot;);
					goto wieder1;
				}
					break;

			case 2:
				if(cFeld2 == '2')
				{
					cFeld2 = cPlayer1;
				}
				else
				{
					cout &lt;&lt; &quot;Feld schon belegt!&quot;;
					system(&quot;pause&gt;nul&quot;);
					goto wieder1;
				}
				break;

			case 3:
				if(cFeld3 == '3')
				{
					cFeld3 = cPlayer1;
				}
				else
				{
					cout &lt;&lt; &quot;Feld schon belegt!&quot;;
					system(&quot;pause&gt;nul&quot;);
					goto wieder1;
				}
				break;

			case 4:
				if(cFeld4 == '4')
				{
					cFeld4 = cPlayer1;
				}
				else
				{
					cout &lt;&lt; &quot;Feld schon belegt!&quot;;
					system(&quot;pause&gt;nul&quot;);
					goto wieder1;
				}
				break;

			case 5:
				if(cFeld5 == '5')
				{
					cFeld5 = cPlayer1;
				}
				else
				{
					cout &lt;&lt; &quot;Feld schon belegt!&quot;;
					system(&quot;pause&gt;nul&quot;);
					goto wieder1;
				}
				break;

			case 6:
				if(cFeld6 == '6')
				{
					cFeld6 = cPlayer1;
				}
				else
				{
					cout &lt;&lt; &quot;Feld schon belegt!&quot;;
					system(&quot;pause&gt;nul&quot;);
					goto wieder1;
				}
				break;

			case 7:
				if(cFeld7 == '7')
				{
					cFeld7 = cPlayer1;
				}
				else
				{
					cout &lt;&lt; &quot;Feld schon belegt!&quot;;
					system(&quot;pause&gt;nul&quot;);
					goto wieder1;
				}
				break;

			case 8:
				if(cFeld8 == '8')
				{
					cFeld8 = cPlayer1;
				}
				else
				{
					cout &lt;&lt; &quot;Feld schon belegt!&quot;;
					system(&quot;pause&gt;nul&quot;);
					goto wieder1;
				}
				break;

			case 9:
				if(cFeld9 == '9')
				{
					cFeld9 = cPlayer1;
				}
				else
				{
					cout &lt;&lt; &quot;Feld schon belegt!&quot;;
					system(&quot;pause&gt;nul&quot;);
					goto wieder1;
				}
				break;
		}

		/* Zu Player 2 */
		wieder2:
		system(&quot;cls&quot;);
		do
		{
			iEingabe = 0 ;

			cout &lt;&lt; cFeld1 &lt;&lt; &quot; | &quot; &lt;&lt; cFeld2 &lt;&lt; &quot; | &quot; &lt;&lt; cFeld3 &lt;&lt; endl
				 &lt;&lt;          &quot;--+-&quot; &lt;&lt;          &quot;--+--&quot; &lt;&lt; endl
				 &lt;&lt; cFeld4 &lt;&lt; &quot; | &quot; &lt;&lt; cFeld5 &lt;&lt; &quot; | &quot; &lt;&lt; cFeld6 &lt;&lt; endl
				 &lt;&lt;          &quot;--+-&quot; &lt;&lt;          &quot;--+--&quot; &lt;&lt; endl
				 &lt;&lt; cFeld7 &lt;&lt; &quot; | &quot; &lt;&lt; cFeld8 &lt;&lt; &quot; | &quot; &lt;&lt; cFeld9 &lt;&lt; endl
				 &lt;&lt; endl
				 &lt;&lt; &quot;Player 2 ist an der Reihe.&quot; &lt;&lt; endl;

			cin &gt;&gt; iEingabe;
			//iEingabe = getch();
			system(&quot;cls&quot;);
		}
		while(iEingabe &gt; 9 || iEingabe &lt; 1 );

		switch(iEingabe)
		{
			case 1:
				if(cFeld1 == '1')
				{
					cFeld1 = cPlayer2;
				}
				else
				{
					cout &lt;&lt; &quot;Feld schon belegt!&quot;;
					system(&quot;pause&gt;nul&quot;);
					goto wieder2;
				}
				break;

			case 2:
				if(cFeld2 == '2')
				{
					cFeld2 = cPlayer2;
				}
				else
				{
					cout &lt;&lt; &quot;Feld schon belegt!&quot;;
					system(&quot;pause&gt;nul&quot;);
					goto wieder2;
				}
				break;

			case 3:
				if(cFeld3 == '3')
				{
					cFeld3 = cPlayer2;
				}
				else
				{
					cout &lt;&lt; &quot;Feld schon belegt!&quot;;
					system(&quot;pause&gt;nul&quot;);
					goto wieder2;
				}
				break;

			case 4:
				if(cFeld4 == '4')
				{
					cFeld4 = cPlayer2;
				}
				else
				{
					cout &lt;&lt; &quot;Feld schon belegt!&quot;;
					system(&quot;pause&gt;nul&quot;);
					goto wieder2;
				}
				break;

			case 5:
				if(cFeld5 == '5')
				{
					cFeld5 = cPlayer2;
				}
				else
				{
					cout &lt;&lt; &quot;Feld schon belegt!&quot;;
					system(&quot;pause&gt;nul&quot;);
					goto wieder2;
				}
				break;

			case 6:
				if(cFeld6 == '6')
				{
					cFeld6 = cPlayer2;
				}
				else
				{
					cout &lt;&lt; &quot;Feld schon belegt!&quot;;
					system(&quot;pause&gt;nul&quot;);
					goto wieder2;
				}
				break;

			case 7:
				if(cFeld7 == '7')
				{
					cFeld7 = cPlayer2;
				}
				else
				{
					cout &lt;&lt; &quot;Feld schon belegt!&quot;;
					system(&quot;pause&gt;nul&quot;);
					goto wieder2;
				}
				break;

			case 8:
				if(cFeld8 == '8')
				{
					cFeld8 = cPlayer2;
				}
				else
				{
					cout &lt;&lt; &quot;Feld schon belegt!&quot;;
					system(&quot;pause&gt;nul&quot;);
					goto wieder2;
				}
				break;

			case 9:
				if(cFeld9 == '9')
				{
					cFeld9 = cPlayer2;
				}
				else
				{
					cout &lt;&lt; &quot;Feld schon belegt!&quot;;
					system(&quot;pause&gt;nul&quot;);
					goto wieder2;
				}
				break;
		}

	}
	while((cFeld1 != cPlayer1 || cFeld2 != cPlayer1 || cFeld3 != cPlayer1) &amp;&amp; (cFeld4 != cPlayer1 || cFeld5 != cPlayer1 || cFeld6 != cPlayer1) &amp;&amp; (cFeld7 != cPlayer1 || cFeld8 != cPlayer1 || cFeld9 != cPlayer1)&amp;&amp; (cFeld1 != cPlayer1 || cFeld4 != cPlayer1 || cFeld7 != cPlayer1)&amp;&amp; (cFeld2 != cPlayer1 || cFeld5 != cPlayer1 || cFeld8 != cPlayer1)&amp;&amp; (cFeld3 != cPlayer1 || cFeld6 != cPlayer1 || cFeld9 != cPlayer1)&amp;&amp; (cFeld3 != cPlayer1 || cFeld5 != cPlayer1 || cFeld7 != cPlayer1)&amp;&amp; (cFeld1 != cPlayer1 || cFeld5 != cPlayer1 || cFeld9 != cPlayer1)&amp;&amp;//Möglichkeiten zu Player 1
		  (cFeld1 != cPlayer2 || cFeld2 != cPlayer2 || cFeld3 != cPlayer2) &amp;&amp; (cFeld4 != cPlayer2 || cFeld5 != cPlayer2 || cFeld6 != cPlayer2) &amp;&amp; (cFeld7 != cPlayer2 || cFeld8 != cPlayer2 || cFeld9 != cPlayer2)&amp;&amp; (cFeld1 != cPlayer2 || cFeld4 != cPlayer2 || cFeld7 != cPlayer2)&amp;&amp; (cFeld2 != cPlayer2 || cFeld5 != cPlayer2 || cFeld8 != cPlayer2)&amp;&amp; (cFeld3 != cPlayer2 || cFeld6 != cPlayer2 || cFeld9 != cPlayer2)&amp;&amp; (cFeld3 != cPlayer2 || cFeld5 != cPlayer2 || cFeld7 != cPlayer2)&amp;&amp; (cFeld1 != cPlayer2 || cFeld5 != cPlayer2 || cFeld9 != cPlayer2));//Möglichkeiten zu Player 2
	cout &lt;&lt; &quot;Player wins&quot; &lt;&lt; endl
		 &lt;&lt; &quot;Nocheinmal? (j/n)&quot;;
	cin &gt;&gt; cjn;
	if(cjn == 'j')
	{
		goto wieder1;
		system(&quot;cls&quot;);
	}
	else
	{
		return 0;
	}
}
</code></pre>
<p>Und ich möchte mich noch einmal bedanken! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2002931</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2002931</guid><dc:creator><![CDATA[Gastschorry]]></dc:creator><pubDate>Wed, 05 Jan 2011 21:22:30 GMT</pubDate></item><item><title><![CDATA[Reply to while-schleife on Wed, 05 Jan 2011 21:31:30 GMT]]></title><description><![CDATA[<p>Und wenn du noch ein wenig weiter gelesen hast, dann überarbeitest du das ganze erstmal gründlich ^^</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2002933</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2002933</guid><dc:creator><![CDATA[HighLigerBiMBam]]></dc:creator><pubDate>Wed, 05 Jan 2011 21:31:30 GMT</pubDate></item><item><title><![CDATA[Reply to while-schleife on Wed, 05 Jan 2011 21:49:15 GMT]]></title><description><![CDATA[<p>Wiso was ist denn noch nicht so gut???<br />
Mhh man merkt wohl das ich noch en anfänger bin <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2002940</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2002940</guid><dc:creator><![CDATA[Gastschorry]]></dc:creator><pubDate>Wed, 05 Jan 2011 21:49:15 GMT</pubDate></item><item><title><![CDATA[Reply to while-schleife on Wed, 05 Jan 2011 21:56:26 GMT]]></title><description><![CDATA[<p>Die Verwendung von goto, die Abwesenheit von Arrays, die Abwesenheit von Funktionen die zu Codeverdoppelung führen. Aber für einen Anfänger ist es ok.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2002943</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2002943</guid><dc:creator><![CDATA[HighLigerBiMBam]]></dc:creator><pubDate>Wed, 05 Jan 2011 21:56:26 GMT</pubDate></item><item><title><![CDATA[Reply to while-schleife on Wed, 05 Jan 2011 22:09:23 GMT]]></title><description><![CDATA[<p>Ja ich weiss das der Befehl goto als Schlampig gilt <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /> wussta aber nicht direkt, wie ich es vermeiden soll : D arrys wollte ich als name nutzen statt diesem player1 und player2...<br />
und funktionen hab ich noch nicht so verstanden : D ...<br />
naja ich bin froh, das ich es überhaupt hinbekommen hab... zwar nicht ohne hilfe aber egal <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2002953</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2002953</guid><dc:creator><![CDATA[Gastschorry]]></dc:creator><pubDate>Wed, 05 Jan 2011 22:09:23 GMT</pubDate></item><item><title><![CDATA[Reply to while-schleife on Thu, 06 Jan 2011 08:04:30 GMT]]></title><description><![CDATA[<p>Gastschorry schrieb:</p>
<blockquote>
<p>Ja ich weiss das der Befehl goto als Schlampig gilt <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /> wussta aber nicht direkt, wie ich es vermeiden soll : D</p>
</blockquote>
<p>goto könntest du mit Schleifen eliminieren. Du verwendest goto ja immer, wenn ein Feld schon belegt ist. Stattdessen könntest du um die Eingabe für einen Spieler einfach ein while(bFeldBelegt) packen. bFeldBelegt ist ein bool und wird erst false, wenn der Spieler eine gültige Eingabe macht.</p>
<p>Gastschorry schrieb:</p>
<blockquote>
<p>arrys wollte ich als name nutzen statt diesem player1 und player2...</p>
</blockquote>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /> Meinst du jetzt, du willst char-Arrays nutzen, um Spielernamen festzuhalten? Das ginge natürlich, du könntest aber auch den wesentlich komfortableren C++-Typen string verwenden. HighLigerBiMBam meinte eher was anderes. Ich habe deinen Code nur ganz kurz überflogen, aber schon die ganzen cFeldx-Variablen könnte man einfach in ein Array packen. Das macht die Sache übersichtlicher und erlaubt z.B. auch das Verarbeiten aller Elemente des Arrays in Schleifen. Mit deinen Einzel-Variablen könntest du sowas nicht.</p>
<p>Gastschorry schrieb:</p>
<blockquote>
<p>und funktionen hab ich noch nicht so verstanden : D ...</p>
</blockquote>
<p>Dann solltest du dich besser heute als morgen damit beschäftigen. Funktionen sind essentiell wichtig. Sie erlauben, wiederkehrende Funktionalität ohne Redundanz (doppelten Code) zu implementieren. Außerdem behältst du nur die Übersicht, wenn du Funktionaltät in Funktionen (und auch Klassen) unterbringst. Stell dir vor, du hast irgendwann ein Programm von 20000 Zeilen. Wenn die alle untereinandergeklatscht sind, blickst du höchstwahrscheinlich nicht mehr durch. Das Suchen von bestimmten Stellen wird zur Qual. Wenn aber alles in kleinen, handlichen Funktionen von nur wenigen Zeilen verpackt ist, lässt sich das alles wesentlich leichter handhaben.</p>
<p>Kleines Beispiel:</p>
<p>Sagen wir mal, du willst (warum auch immer <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="😉"
    /> ) mehrfach Multiplikationen durchführen und das Ergebnis auf der Konsole ausgeben.</p>
<p>So sieht es ohne Funktion aus (jede Menge redundanter Code, unschön):</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;

using namespace std;

int main() {
  cout &lt;&lt; &quot;Das Produkt von &quot; &lt;&lt; 2 &lt;&lt; &quot; und &quot; &lt;&lt; 3 &lt;&lt; &quot; ist &quot; &lt;&lt; 2*3 &lt;&lt; &quot;.&quot;;
  cout &lt;&lt; &quot;Das Produkt von &quot; &lt;&lt; 6 &lt;&lt; &quot; und &quot; &lt;&lt; 8 &lt;&lt; &quot; ist &quot; &lt;&lt; 6*8 &lt;&lt; &quot;.&quot;;
  cout &lt;&lt; &quot;Das Produkt von &quot; &lt;&lt; 9 &lt;&lt; &quot; und &quot; &lt;&lt; 5 &lt;&lt; &quot; ist &quot; &lt;&lt; 9*5 &lt;&lt; &quot;.&quot;;
  cout &lt;&lt; &quot;Das Produkt von &quot; &lt;&lt; 3 &lt;&lt; &quot; und &quot; &lt;&lt; 6 &lt;&lt; &quot; ist &quot; &lt;&lt; 3*6 &lt;&lt; &quot;.&quot;;
  cout &lt;&lt; &quot;Das Produkt von &quot; &lt;&lt; 4 &lt;&lt; &quot; und &quot; &lt;&lt; 1 &lt;&lt; &quot; ist &quot; &lt;&lt; 4*1 &lt;&lt; &quot;.&quot;;
  cout &lt;&lt; &quot;Das Produkt von &quot; &lt;&lt; 0 &lt;&lt; &quot; und &quot; &lt;&lt; 9 &lt;&lt; &quot; ist &quot; &lt;&lt; 0*9 &lt;&lt; &quot;.&quot;;
  cout &lt;&lt; &quot;Das Produkt von &quot; &lt;&lt; 5 &lt;&lt; &quot; und &quot; &lt;&lt; 4 &lt;&lt; &quot; ist &quot; &lt;&lt; 5*4 &lt;&lt; &quot;.&quot;;
  cout &lt;&lt; &quot;Das Produkt von &quot; &lt;&lt; 5 &lt;&lt; &quot; und &quot; &lt;&lt; 4 &lt;&lt; &quot; ist &quot; &lt;&lt; 5*4 &lt;&lt; &quot;.&quot;;
  cout &lt;&lt; &quot;Das Produkt von &quot; &lt;&lt; 2 &lt;&lt; &quot; und &quot; &lt;&lt; 6 &lt;&lt; &quot; ist &quot; &lt;&lt; 2*6 &lt;&lt; &quot;.&quot;;
  cout &lt;&lt; &quot;Das Produkt von &quot; &lt;&lt; 7 &lt;&lt; &quot; und &quot; &lt;&lt; 7 &lt;&lt; &quot; ist &quot; &lt;&lt; 7*7 &lt;&lt; &quot;.&quot;;
}
</code></pre>
<p>Und so könnte es mit einer Funktion aussehen:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;

using namespace std;

void druckeProdukt(int a,int b) {
  cout &lt;&lt; &quot;Das Produkt von &quot; &lt;&lt; a &lt;&lt; &quot; und &quot; &lt;&lt; b &lt;&lt; &quot; ist &quot; &lt;&lt; a*b &lt;&lt; &quot;.&quot;;
}

int main() {
  druckeProdukt(2,3);  
  druckeProdukt(6,8);  
  druckeProdukt(9,5);  
  druckeProdukt(3,6);  
  druckeProdukt(4,1);  
  druckeProdukt(0,9);  
  druckeProdukt(5,4);  
  druckeProdukt(5,4);  
  druckeProdukt(2,6);  
  druckeProdukt(7,7);  
}
</code></pre>
<p>Und nun bedenke noch, dass du im letzteren Fall ganz einfach die Funktionalität deines Programms ändern kannst. Wenn z.B. der Text anders sein soll, musst du nur eine Stelle (nämlich die Funktion) ändern, anstatt in 10 Zeilen rumzupfuschen.</p>
<p>Gastschorry schrieb:</p>
<blockquote>
<p>naja ich bin froh, das ich es überhaupt hinbekommen hab... zwar nicht ohne hilfe aber egal <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
</blockquote>
<p>Ist doch schon mal was. Übung macht den Meister! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2003009</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2003009</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Thu, 06 Jan 2011 08:04:30 GMT</pubDate></item></channel></rss>