<?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[Brauche Hilfe bei Spiel!!!]]></title><description><![CDATA[<p>Hi leute,</p>
<p>habe folgenden Code:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;windows.h&gt;
using namespace std;

const int X = 9;
const int Y = 7;

char Spielfeld[X][Y];
char cx, cy;

int xin, yin;

bool val;

void Zeichnen();
void Eingabe();

int main()
{

	for(int x = 0; x &lt; X; x++)
	{
		for(int y = 0; y &lt; Y; y++)
		{
			Spielfeld[x][y] = '.';
		}
	}

	//////////////////////////////////////////////////////////////////////////////////////////////////////////////

	do
	{
		do
		{

			Zeichnen();

			Eingabe();

			system(&quot;cls&quot;);

		} while(!val);

	} while(true);

/////////////////////////////////////////////////////////////////////////////////////////////////////////////

}

void Zeichnen()
{

	cout &lt;&lt; &quot;    1   2   3   4   5   6   7   8   9&quot; &lt;&lt; endl;
	for(int y = 0; y &lt; Y; y++)
	{
		cout &lt;&lt; (char) ('A' + y);
		for(int x = 0; x &lt; X; x++)
		{
			cout &lt;&lt; &quot;   &quot; &lt;&lt; Spielfeld[x][y];
		}
		cout &lt;&lt; endl;
	}

}

void Eingabe()
{
	val = true;

	cin &gt;&gt; cx &gt;&gt; cy;
	cin.ignore();

	xin = cx - '1';
	yin = cy - 'A';

	if(xin &gt;= 0 &amp;&amp; xin &lt; X &amp;&amp; yin &gt;= 0 &amp;&amp; yin &lt; Y)
	{
		Spielfeld[xin][yin] = 'x';
	}
	else
	{
		cout &lt;&lt; &quot;Falsche Eingabe, erneut eingeben!&quot; &lt;&lt; endl;
		Sleep(1000);
		val = false;
	}

}
</code></pre>
<p>Mein Problem ist:</p>
<p>Wenn ich eine lange Falsche Eingabe mache, z.B. 1k2jk1j32lj3k2j3k2j3k2j3l2j3k2, dann wird &quot;Falsche Eingabe, erneut eingeben!&quot; voll lange angezeigt.</p>
<p>Wenn ich nur 1k1k1 eingebe dann wird die vorgegebene 1 Sekunde angezeigt.</p>
<p>Mann muss zuerst eine Zahl und dann Buchstabe eingeben, z.B. 5C.</p>
<p>Ihr müsst den Code kopieren, damit ihr wisst was ihr meine <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>
<p>Hoffe ihr könnt mir helfen <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>
<p>Weiß einfach nicht mehr weiter.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/307885/brauche-hilfe-bei-spiel</link><generator>RSS for Node</generator><lastBuildDate>Thu, 06 Aug 2026 15:58:18 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/307885.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 07 Sep 2012 19:33:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Brauche Hilfe bei Spiel!!! on Fri, 07 Sep 2012 19:33:39 GMT]]></title><description><![CDATA[<p>Hi leute,</p>
<p>habe folgenden Code:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;windows.h&gt;
using namespace std;

const int X = 9;
const int Y = 7;

char Spielfeld[X][Y];
char cx, cy;

int xin, yin;

bool val;

void Zeichnen();
void Eingabe();

int main()
{

	for(int x = 0; x &lt; X; x++)
	{
		for(int y = 0; y &lt; Y; y++)
		{
			Spielfeld[x][y] = '.';
		}
	}

	//////////////////////////////////////////////////////////////////////////////////////////////////////////////

	do
	{
		do
		{

			Zeichnen();

			Eingabe();

			system(&quot;cls&quot;);

		} while(!val);

	} while(true);

/////////////////////////////////////////////////////////////////////////////////////////////////////////////

}

void Zeichnen()
{

	cout &lt;&lt; &quot;    1   2   3   4   5   6   7   8   9&quot; &lt;&lt; endl;
	for(int y = 0; y &lt; Y; y++)
	{
		cout &lt;&lt; (char) ('A' + y);
		for(int x = 0; x &lt; X; x++)
		{
			cout &lt;&lt; &quot;   &quot; &lt;&lt; Spielfeld[x][y];
		}
		cout &lt;&lt; endl;
	}

}

void Eingabe()
{
	val = true;

	cin &gt;&gt; cx &gt;&gt; cy;
	cin.ignore();

	xin = cx - '1';
	yin = cy - 'A';

	if(xin &gt;= 0 &amp;&amp; xin &lt; X &amp;&amp; yin &gt;= 0 &amp;&amp; yin &lt; Y)
	{
		Spielfeld[xin][yin] = 'x';
	}
	else
	{
		cout &lt;&lt; &quot;Falsche Eingabe, erneut eingeben!&quot; &lt;&lt; endl;
		Sleep(1000);
		val = false;
	}

}
</code></pre>
<p>Mein Problem ist:</p>
<p>Wenn ich eine lange Falsche Eingabe mache, z.B. 1k2jk1j32lj3k2j3k2j3k2j3l2j3k2, dann wird &quot;Falsche Eingabe, erneut eingeben!&quot; voll lange angezeigt.</p>
<p>Wenn ich nur 1k1k1 eingebe dann wird die vorgegebene 1 Sekunde angezeigt.</p>
<p>Mann muss zuerst eine Zahl und dann Buchstabe eingeben, z.B. 5C.</p>
<p>Ihr müsst den Code kopieren, damit ihr wisst was ihr meine <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>
<p>Hoffe ihr könnt mir helfen <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>
<p>Weiß einfach nicht mehr weiter.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2249467</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2249467</guid><dc:creator><![CDATA[DerDebugger]]></dc:creator><pubDate>Fri, 07 Sep 2012 19:33:39 GMT</pubDate></item><item><title><![CDATA[Reply to Brauche Hilfe bei Spiel!!! on Fri, 07 Sep 2012 19:37:12 GMT]]></title><description><![CDATA[<p>Der Code wird so lange abgearbeitet bis der Eingabepuffer mit 1k2jk1j32lj3k2j3k2j3k2j3l2j3k2 leer ist. cin entfernt die ersten beiden character und lässt den Rest bis zum nächsten durchgang stehen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2249468</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2249468</guid><dc:creator><![CDATA[qweqwrtgsdxgfvdfgdg]]></dc:creator><pubDate>Fri, 07 Sep 2012 19:37:12 GMT</pubDate></item><item><title><![CDATA[Reply to Brauche Hilfe bei Spiel!!! on Fri, 07 Sep 2012 19:54:37 GMT]]></title><description><![CDATA[<p>qweqwrtgsdxgfvdfgdg schrieb:</p>
<blockquote>
<p>Der Code wird so lange abgearbeitet bis der Eingabepuffer mit 1k2jk1j32lj3k2j3k2j3k2j3l2j3k2 leer ist. cin entfernt die ersten beiden character und lässt den Rest bis zum nächsten durchgang stehen.</p>
</blockquote>
<p>Und wie lösche ich den restlichen Puffer?</p>
<p>Ist das nicht der cin.ignore() Befehl in meinem Code?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2249470</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2249470</guid><dc:creator><![CDATA[DerDebugger]]></dc:creator><pubDate>Fri, 07 Sep 2012 19:54:37 GMT</pubDate></item><item><title><![CDATA[Reply to Brauche Hilfe bei Spiel!!! on Sat, 08 Sep 2012 09:01:47 GMT]]></title><description><![CDATA[<p>So entfernst du nur genau 1 Zeichen, s. <a href="http://www.cplusplus.com/reference/iostream/istream/ignore" rel="nofollow">http://www.cplusplus.com/reference/iostream/istream/ignore</a></p>
<p>Die korrekt Antwort steht in <a href="http://www.c-plusplus.net/forum/111042" rel="nofollow">Automatisches Schließen verhindern</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2249531</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2249531</guid><dc:creator><![CDATA[Th69]]></dc:creator><pubDate>Sat, 08 Sep 2012 09:01:47 GMT</pubDate></item></channel></rss>