<?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[[Anfänger] | Ausgabe gibt &amp;quot;falsch&amp;quot; aus]]></title><description><![CDATA[<p>Hallo, ich bin neu in der Sprache C++ und habe mir auch ein Buch gekauft. Allerdings komme ich einfach nicht weiter weil ich meinen Denkfehler nicht finde. Und zwar gibt mir folgender Quelltext &quot;falsche&quot; Daten aus:</p>
<pre><code>#include &lt;iostream&gt;
using namespace std;

enum Ampel {rot, gelb, gruen};

int main() {
	Ampel ampel = rot;

	for(int n = 0; n &lt; 3; ++n) {
		switch(n) {
		case rot: cout &lt;&lt; &quot;ROT&quot; &lt;&lt; endl;
		case gelb: cout &lt;&lt; &quot;GELB&quot; &lt;&lt; endl;
		case gruen: cout &lt;&lt; &quot;GRUEN&quot; &lt;&lt; endl;
		}

		ampel = static_cast&lt;Ampel&gt;(ampel + 1);
	}
}
</code></pre>
<p>Es erscheint folgende Ausgabe:</p>
<blockquote>
<p>ROT<br />
GELB<br />
GRUEN<br />
GELB<br />
GRUEN<br />
GRUEN</p>
</blockquote>
<p>Allerdings soll diese so aussehen:</p>
<blockquote>
<p>ROT<br />
GELB<br />
GRUEN</p>
</blockquote>
<p>Kann mir da eventuell einer bei helfen und mir sagen was ich da falsch mache?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/312193/anfänger-ausgabe-gibt-quot-falsch-quot-aus</link><generator>RSS for Node</generator><lastBuildDate>Mon, 03 Aug 2026 02:48:42 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/312193.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 28 Dec 2012 09:13:22 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [Anfänger] | Ausgabe gibt &amp;quot;falsch&amp;quot; aus on Fri, 28 Dec 2012 09:15:43 GMT]]></title><description><![CDATA[<p>Hallo, ich bin neu in der Sprache C++ und habe mir auch ein Buch gekauft. Allerdings komme ich einfach nicht weiter weil ich meinen Denkfehler nicht finde. Und zwar gibt mir folgender Quelltext &quot;falsche&quot; Daten aus:</p>
<pre><code>#include &lt;iostream&gt;
using namespace std;

enum Ampel {rot, gelb, gruen};

int main() {
	Ampel ampel = rot;

	for(int n = 0; n &lt; 3; ++n) {
		switch(n) {
		case rot: cout &lt;&lt; &quot;ROT&quot; &lt;&lt; endl;
		case gelb: cout &lt;&lt; &quot;GELB&quot; &lt;&lt; endl;
		case gruen: cout &lt;&lt; &quot;GRUEN&quot; &lt;&lt; endl;
		}

		ampel = static_cast&lt;Ampel&gt;(ampel + 1);
	}
}
</code></pre>
<p>Es erscheint folgende Ausgabe:</p>
<blockquote>
<p>ROT<br />
GELB<br />
GRUEN<br />
GELB<br />
GRUEN<br />
GRUEN</p>
</blockquote>
<p>Allerdings soll diese so aussehen:</p>
<blockquote>
<p>ROT<br />
GELB<br />
GRUEN</p>
</blockquote>
<p>Kann mir da eventuell einer bei helfen und mir sagen was ich da falsch mache?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2283835</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2283835</guid><dc:creator><![CDATA[Make-Grafik]]></dc:creator><pubDate>Fri, 28 Dec 2012 09:15:43 GMT</pubDate></item><item><title><![CDATA[Reply to [Anfänger] | Ausgabe gibt &amp;quot;falsch&amp;quot; aus on Fri, 28 Dec 2012 09:36:31 GMT]]></title><description><![CDATA[<p>Wenn ein case-Zweig als wahr erkannt wird, läuft das Programm von da ab sequentiell weiter, und führt auch die zu den folgenden case-Zweigen gehörenden Instruktionen aus.<br />
Wenn das nicht gewünscht ist, schließt man einen case-Zweig mit break ab:</p>
<pre><code>switch(...)
{
  case bla:
    ... 
    ...
    break;
  case blup:
    ...
    break;
  ...
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2283844</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2283844</guid><dc:creator><![CDATA[Belli]]></dc:creator><pubDate>Fri, 28 Dec 2012 09:36:31 GMT</pubDate></item><item><title><![CDATA[Reply to [Anfänger] | Ausgabe gibt &amp;quot;falsch&amp;quot; aus on Fri, 28 Dec 2012 09:41:02 GMT]]></title><description><![CDATA[<p>Öhm :o</p>
<blockquote>
<p>.&lt;</p>
</blockquote>
<p>Ja, danke <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61b.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_tongue"
      title=":P"
      alt="😛"
    /><br />
Jetzt bin ich wieder schlauer <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f4a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--light_bulb"
      title=":bulb:"
      alt="💡"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2283846</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2283846</guid><dc:creator><![CDATA[Make-Grafik]]></dc:creator><pubDate>Fri, 28 Dec 2012 09:41:02 GMT</pubDate></item></channel></rss>