<?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[Diesmal ein Problem mit der While Schleife^^]]></title><description><![CDATA[<p>Hi</p>
<p>Ich habe diesen Code geschrieben:</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;cstdlib&gt;
#include &lt;ctime&gt;
using namespace std;

int main()
{
	time_t sek;
	cout &lt;&lt; &quot;\nRaten Sie eine Zahl zwischen 1 - 15!\n&quot;;
	time( &amp;sek);
	srand( static_cast &lt;unsigned int&gt; (sek) );
	const long zahl = (rand()%15)+1;
	bool eingabe = false;
	int zahl1, versuch = 1;
	char wb = 'w';// Das ganze Wb zeug stand so in meinem Buch^^
	while (wb == 'w')// also das
	{
		while(eingabe == false &amp;&amp; versuch &lt;= 3)
		{
			cin &gt;&gt; zahl1;
			if (zahl1 == zahl)
			{
				eingabe = true;
				cout &lt;&lt; &quot;Richtiiiig!!! :D\n&quot;;
			}
			if (zahl1 &lt; zahl)
			{
				++versuch;
				cout &lt;&lt; &quot;Die Zahl ist zu klein, geben Sie eine neue ein!\n&quot;;
			}
			if (zahl1 &gt; zahl)
			{
				++versuch;
				cout &lt;&lt; &quot;Die Zahl ist zu gros, geben Sie eine neue ein!\n&quot;;
			}
		}
		if (eingabe = false)
		{
			cout &lt;&lt; &quot;Sie haben leider verloren die gesuchte Zahl war: &quot; &lt;&lt; zahl 
				 &lt;&lt; &quot; möchten Sie das Spiel wieder holen?\n&quot;
				 &lt;&lt; &quot;Wiederholen --&gt; [W]  Beenden --&gt; [B]&quot;;// und das
		}
		else
		{
			cout &lt;&lt; &quot;Sehr Gut Sie haben Gewonnen! Möchten Sie das Spiel wiederholen?&quot;
				 &lt;&lt; &quot;Wiederholen --&gt; [W]  Beenden --&gt; [B]&quot;;// und das^^
		}
	}
		do
		cin &gt;&gt; wb;
		while ( wb != 'w' &amp;&amp; wb != 'b');//und das natürlich^^
}
</code></pre>
<p>So... es hatt halt erst alles geklappt mit dem erraten usw. aber seit ich das mit dem Beenden eingefügt habe verläuft sich das Programm in einer endlos schleife und zeigt die ganze Zeit den &quot;wiederholen --&gt; [W]... Teil an^^</p>
<p>Ich weiß warscheinlich wirds mal wieder was extrem dummes sein wo mann auch selber drauf kommen könnte:)</p>
<p>Hoffe ihr helft mir trotzdem <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>LG</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/228160/diesmal-ein-problem-mit-der-while-schleife</link><generator>RSS for Node</generator><lastBuildDate>Tue, 29 Sep 2026 17:55:24 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/228160.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 24 Nov 2008 20:44:38 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Diesmal ein Problem mit der While Schleife^^ on Mon, 24 Nov 2008 20:44:38 GMT]]></title><description><![CDATA[<p>Hi</p>
<p>Ich habe diesen Code geschrieben:</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;cstdlib&gt;
#include &lt;ctime&gt;
using namespace std;

int main()
{
	time_t sek;
	cout &lt;&lt; &quot;\nRaten Sie eine Zahl zwischen 1 - 15!\n&quot;;
	time( &amp;sek);
	srand( static_cast &lt;unsigned int&gt; (sek) );
	const long zahl = (rand()%15)+1;
	bool eingabe = false;
	int zahl1, versuch = 1;
	char wb = 'w';// Das ganze Wb zeug stand so in meinem Buch^^
	while (wb == 'w')// also das
	{
		while(eingabe == false &amp;&amp; versuch &lt;= 3)
		{
			cin &gt;&gt; zahl1;
			if (zahl1 == zahl)
			{
				eingabe = true;
				cout &lt;&lt; &quot;Richtiiiig!!! :D\n&quot;;
			}
			if (zahl1 &lt; zahl)
			{
				++versuch;
				cout &lt;&lt; &quot;Die Zahl ist zu klein, geben Sie eine neue ein!\n&quot;;
			}
			if (zahl1 &gt; zahl)
			{
				++versuch;
				cout &lt;&lt; &quot;Die Zahl ist zu gros, geben Sie eine neue ein!\n&quot;;
			}
		}
		if (eingabe = false)
		{
			cout &lt;&lt; &quot;Sie haben leider verloren die gesuchte Zahl war: &quot; &lt;&lt; zahl 
				 &lt;&lt; &quot; möchten Sie das Spiel wieder holen?\n&quot;
				 &lt;&lt; &quot;Wiederholen --&gt; [W]  Beenden --&gt; [B]&quot;;// und das
		}
		else
		{
			cout &lt;&lt; &quot;Sehr Gut Sie haben Gewonnen! Möchten Sie das Spiel wiederholen?&quot;
				 &lt;&lt; &quot;Wiederholen --&gt; [W]  Beenden --&gt; [B]&quot;;// und das^^
		}
	}
		do
		cin &gt;&gt; wb;
		while ( wb != 'w' &amp;&amp; wb != 'b');//und das natürlich^^
}
</code></pre>
<p>So... es hatt halt erst alles geklappt mit dem erraten usw. aber seit ich das mit dem Beenden eingefügt habe verläuft sich das Programm in einer endlos schleife und zeigt die ganze Zeit den &quot;wiederholen --&gt; [W]... Teil an^^</p>
<p>Ich weiß warscheinlich wirds mal wieder was extrem dummes sein wo mann auch selber drauf kommen könnte:)</p>
<p>Hoffe ihr helft mir trotzdem <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>LG</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1620173</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1620173</guid><dc:creator><![CDATA[wurstuk]]></dc:creator><pubDate>Mon, 24 Nov 2008 20:44:38 GMT</pubDate></item><item><title><![CDATA[Reply to Diesmal ein Problem mit der While Schleife^^ on Mon, 24 Nov 2008 20:59:44 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">if (eingabe = false)
</code></pre>
<p>Ist wohl nicht so gemeint <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/1620180</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1620180</guid><dc:creator><![CDATA[Maxi]]></dc:creator><pubDate>Mon, 24 Nov 2008 20:59:44 GMT</pubDate></item><item><title><![CDATA[Reply to Diesmal ein Problem mit der While Schleife^^ on Mon, 24 Nov 2008 21:09:19 GMT]]></title><description><![CDATA[<p>Der Gleichheitsoperator ist in C++ <code>==</code> und nicht <code>=</code> .</p>
<p>Ausserdem kann man statt</p>
<pre><code class="language-cpp">if (Var == false)
</code></pre>
<p>natürlich</p>
<pre><code class="language-cpp">if (!Var)
</code></pre>
<p>schreiben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1620184</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1620184</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Mon, 24 Nov 2008 21:09:19 GMT</pubDate></item><item><title><![CDATA[Reply to Diesmal ein Problem mit der While Schleife^^ on Tue, 25 Nov 2008 07:23:45 GMT]]></title><description><![CDATA[<p>So habs jetzt geändert aber bringen tut es trotzdem nichts....</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;cstdlib&gt;
#include &lt;ctime&gt;
using namespace std;

int main()
{
	time_t sek;
	cout &lt;&lt; &quot;\nRaten Sie eine Zahl zwischen 1 - 15!\n&quot;;
	time( &amp;sek);
	srand( static_cast &lt;unsigned int&gt; (sek) );
	const long zahl = (rand()%15)+1;
	bool eingabe = false;
	int zahl1, versuch = 1;
	char wb = 'w';
	while (wb == 'w')
	{
		while(eingabe == false &amp;&amp; versuch &lt;= 3)
		{
			cin &gt;&gt; zahl1;
			if (zahl1 == zahl)
			{
				eingabe = true;
				cout &lt;&lt; &quot;Richtiiiig!!! :D\n&quot;;
			}
			if (zahl1 &lt; zahl)
			{
				++versuch;
				cout &lt;&lt; &quot;Die Zahl ist zu klein, geben Sie eine neue ein!\n&quot;;
			}
			if (zahl1 &gt; zahl)
			{
				++versuch;
				cout &lt;&lt; &quot;Die Zahl ist zu gros, geben Sie eine neue ein!\n&quot;;
			}
		}
		if (eingabe == false)
		{
			cout &lt;&lt; &quot;Sie haben leider verloren die gesuchte Zahl war: &quot; &lt;&lt; zahl 
				 &lt;&lt; &quot; möchten Sie das Spiel wieder holen?\n&quot;
				 &lt;&lt; &quot;Wiederholen --&gt; [W]  Beenden --&gt; [B]&quot;;
		}
		else
		{
			cout &lt;&lt; &quot;Sehr Gut Sie haben Gewonnen! Möchten Sie das Spiel wiederholen?&quot;
				 &lt;&lt; &quot;Wiederholen --&gt; [W]  Beenden --&gt; [B]&quot;;
		}
	}
		do
		cin &gt;&gt; wb;
		while ( wb != 'w' &amp;&amp; wb != 'b');
}
</code></pre>
<p>trotzdem Danke!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1620275</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1620275</guid><dc:creator><![CDATA[wurstuk]]></dc:creator><pubDate>Tue, 25 Nov 2008 07:23:45 GMT</pubDate></item><item><title><![CDATA[Reply to Diesmal ein Problem mit der While Schleife^^ on Tue, 25 Nov 2008 07:40:05 GMT]]></title><description><![CDATA[<blockquote>
<pre><code class="language-cpp">do
        cin &gt;&gt; wb;
        while ( wb != 'w' &amp;&amp; wb != 'b');
</code></pre>
</blockquote>
<p>Ich bezweifle mal, dass das am richtigen Ort steht..</p>
<p>Bei dir kann diese Bedingung:</p>
<pre><code class="language-cpp">while (wb == 'w')
</code></pre>
<p>gar nie nicht erfüllt sein, weil du wb nirgends veränderst. Daher solltest du wohl eher in der Schleife die Abfrage machen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1620280</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1620280</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Tue, 25 Nov 2008 07:40:05 GMT</pubDate></item></channel></rss>