<?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[Schleife in switch Anweisung]]></title><description><![CDATA[<p>Moin Leudz,</p>
<p>wie man unten sehen kann möchte ich ne Schleife in eine switch anweisung einbauen(Die Schleife ist im Mom inaktiv, damit das Programm trotzdem läuft).</p>
<p>Ich bekomme dann aber immer Syntax Fehler ausgegeben:</p>
<p>143 D:\Dokumente und Einstellungen\ich\Eigene Dateien\C++Programme\Aktionär\spiel.cpp syntax error before `!' token und</p>
<p>165 D:\Dokumente und Einstellungen\ich\Eigene Dateien\C++Programme\Aktionär\spiel.cpp syntax error before `}' token</p>
<pre><code>switch(auswahl)
     {
         case 1 : {short test=0;
                  //do
                  //{
                  short Firma=0;
                  short Anzahl=0;
                  cout&lt;&lt;&quot;\nVon welcher Firma moechtest du kaufen? &quot;;
                  cin&gt;&gt;Firma;
                  cout&lt;&lt;&quot;\nWie viele Aktien möchtest du kaufen? &quot;;
                  cin&gt;&gt;Anzahl;
                  if(Firma ==1)
                  {ab1 = ab1+Anzahl;
                   geld = geld - (aktienkurs1 * Anzahl);
                   }
                  else 
                  {if (Firma == 2)
                  {ab2 = ab2+Anzahl;
                   geld = geld - (aktienkurs2 * Anzahl);}
                   else
                   {ab3 = ab3+Anzahl;
                   geld = geld - (aktienkurs3 * Anzahl);}}
                   cout&lt;&lt;&quot;Was möchtest du jetzt tun? &quot;;
                   cout&lt;&lt;&quot;\n1. Nochmal kaufen  2. Verkaufen &lt;inaktiv&gt;  3. Einen Tag weiter gehen: &quot;;
                   cin&gt;&gt;test;//}
                   //while (test != 3);
                   };break;
</code></pre>
<p>Danke für eure Hilfe</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/128904/schleife-in-switch-anweisung</link><generator>RSS for Node</generator><lastBuildDate>Tue, 25 Aug 2026 22:09:16 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/128904.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 08 Dec 2005 12:49:13 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Schleife in switch Anweisung on Thu, 08 Dec 2005 12:49:13 GMT]]></title><description><![CDATA[<p>Moin Leudz,</p>
<p>wie man unten sehen kann möchte ich ne Schleife in eine switch anweisung einbauen(Die Schleife ist im Mom inaktiv, damit das Programm trotzdem läuft).</p>
<p>Ich bekomme dann aber immer Syntax Fehler ausgegeben:</p>
<p>143 D:\Dokumente und Einstellungen\ich\Eigene Dateien\C++Programme\Aktionär\spiel.cpp syntax error before `!' token und</p>
<p>165 D:\Dokumente und Einstellungen\ich\Eigene Dateien\C++Programme\Aktionär\spiel.cpp syntax error before `}' token</p>
<pre><code>switch(auswahl)
     {
         case 1 : {short test=0;
                  //do
                  //{
                  short Firma=0;
                  short Anzahl=0;
                  cout&lt;&lt;&quot;\nVon welcher Firma moechtest du kaufen? &quot;;
                  cin&gt;&gt;Firma;
                  cout&lt;&lt;&quot;\nWie viele Aktien möchtest du kaufen? &quot;;
                  cin&gt;&gt;Anzahl;
                  if(Firma ==1)
                  {ab1 = ab1+Anzahl;
                   geld = geld - (aktienkurs1 * Anzahl);
                   }
                  else 
                  {if (Firma == 2)
                  {ab2 = ab2+Anzahl;
                   geld = geld - (aktienkurs2 * Anzahl);}
                   else
                   {ab3 = ab3+Anzahl;
                   geld = geld - (aktienkurs3 * Anzahl);}}
                   cout&lt;&lt;&quot;Was möchtest du jetzt tun? &quot;;
                   cout&lt;&lt;&quot;\n1. Nochmal kaufen  2. Verkaufen &lt;inaktiv&gt;  3. Einen Tag weiter gehen: &quot;;
                   cin&gt;&gt;test;//}
                   //while (test != 3);
                   };break;
</code></pre>
<p>Danke für eure Hilfe</p>
]]></description><link>https://www.c-plusplus.net/forum/post/937257</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/937257</guid><dc:creator><![CDATA[Shihan]]></dc:creator><pubDate>Thu, 08 Dec 2005 12:49:13 GMT</pubDate></item><item><title><![CDATA[Reply to Schleife in switch Anweisung on Thu, 08 Dec 2005 12:58:19 GMT]]></title><description><![CDATA[<p>Boah, könntest du den Code nicht übersichtlicher gestalten? Und poste bitte den Code mit der while Anweisung und allen drum und dran und den Zeilennummern, damit man da auch was finden kann. Echt schrecklich der Code, so wie er jetzt ist.</p>
<p>MfG Riddick04</p>
]]></description><link>https://www.c-plusplus.net/forum/post/937276</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/937276</guid><dc:creator><![CDATA[Riddick04]]></dc:creator><pubDate>Thu, 08 Dec 2005 12:58:19 GMT</pubDate></item><item><title><![CDATA[Reply to Schleife in switch Anweisung on Thu, 08 Dec 2005 13:01:33 GMT]]></title><description><![CDATA[<p>So ein paar</p>
<pre><code class="language-cpp">Tags und ein bißchen bessere Einrückung als Service 

Moin Leudz,

wie man unten sehen kann möchte ich ne Schleife in eine switch anweisung einbauen(Die Schleife ist im Mom inaktiv, damit das Programm trotzdem läuft).

Ich bekomme dann aber immer Syntax Fehler ausgegeben:

143 D:\Dokumente und Einstellungen\ich\Eigene Dateien\C++Programme\Aktionär\spiel.cpp syntax error before `!' token und

165 D:\Dokumente und Einstellungen\ich\Eigene Dateien\C++Programme\Aktionär\spiel.cpp syntax error before `}' token 

[cpp]
case 1 : 
{
   short test=0;
   do
   {
      short Firma=0;
      short Anzahl=0;
      cout&lt;&lt;&quot;\nVon welcher Firma moechtest du kaufen? &quot;;
      cin&gt;&gt;Firma;
      cout&lt;&lt;&quot;\nWie viele Aktien möchtest du kaufen? &quot;;
      cin&gt;&gt;Anzahl;
      if(Firma == 1)
      {
         ab1 = ab1+Anzahl;
         geld = geld - (aktienkurs1 * Anzahl);
      }
      else 
      {
         if (Firma == 2)
         {
            ab2 = ab2+Anzahl;
            geld = geld - (aktienkurs2 * Anzahl);
         }
         else
         {
            ab3 = ab3+Anzahl;
            geld = geld - (aktienkurs3 * Anzahl);
         }
      }
      cout&lt;&lt;&quot;Was möchtest du jetzt tun? &quot;;
      cout&lt;&lt;&quot;\n1. Nochmal kaufen  2. Verkaufen &lt;inaktiv&gt;  3. Einen Tag weiter gehen: &quot;;
      cin&gt;&gt;test;
   } while (test != 3);
};
break;
</code></pre>
<p>Danke für eure Hilfe</p>
]]></description><link>https://www.c-plusplus.net/forum/post/937278</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/937278</guid><dc:creator><![CDATA[templäd]]></dc:creator><pubDate>Thu, 08 Dec 2005 13:01:33 GMT</pubDate></item><item><title><![CDATA[Reply to Schleife in switch Anweisung on Thu, 08 Dec 2005 13:10:49 GMT]]></title><description><![CDATA[<p>Könnte an den geschweiften Klammern liegen nach dem case, probiers mal so:</p>
<pre><code class="language-cpp">case 1 :
   short test=0;
   do
   {
      short Firma=0;
      short Anzahl=0;
      cout&lt;&lt;&quot;\nVon welcher Firma moechtest du kaufen? &quot;;
      cin&gt;&gt;Firma;
      cout&lt;&lt;&quot;\nWie viele Aktien möchtest du kaufen? &quot;;
      cin&gt;&gt;Anzahl;
      if(Firma == 1)
      {
         ab1 = ab1+Anzahl;
         geld = geld - (aktienkurs1 * Anzahl);
      }
      else
      {
         if (Firma == 2)
         {
            ab2 = ab2+Anzahl;
            geld = geld - (aktienkurs2 * Anzahl);
         }
         else
         {
            ab3 = ab3+Anzahl;
            geld = geld - (aktienkurs3 * Anzahl);
         }
      }
      cout&lt;&lt;&quot;Was möchtest du jetzt tun? &quot;;
      cout&lt;&lt;&quot;\n1. Nochmal kaufen  2. Verkaufen &lt;inaktiv&gt;  3. Einen Tag weiter gehen: &quot;;
      cin&gt;&gt;test;
   } while (test != 3);
break;
</code></pre>
<p>MfG Riddick04</p>
<p>EDIT: Und vielen Dank an templäd für den hilfreichen Service <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="😉"
    /> war echt schrecklich der Code vorher.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/937286</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/937286</guid><dc:creator><![CDATA[Riddick04]]></dc:creator><pubDate>Thu, 08 Dec 2005 13:10:49 GMT</pubDate></item><item><title><![CDATA[Reply to Schleife in switch Anweisung on Thu, 08 Dec 2005 15:05:01 GMT]]></title><description><![CDATA[<p>Moin Leudz,</p>
<p>leider hats nicht funktioniert, aber danke für eure Hilfe. Hab mir was anderes einfallen lassen. Und danke für die Tipps mit der Übersichtlichkeit, werde si mir merken. Danke.</p>
<p>Gruß Shihan</p>
]]></description><link>https://www.c-plusplus.net/forum/post/937434</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/937434</guid><dc:creator><![CDATA[Shihan]]></dc:creator><pubDate>Thu, 08 Dec 2005 15:05:01 GMT</pubDate></item><item><title><![CDATA[Reply to Schleife in switch Anweisung on Thu, 08 Dec 2005 15:36:51 GMT]]></title><description><![CDATA[<p>Riddick04 schrieb:</p>
<blockquote>
<p>Könnte an den geschweiften Klammern liegen nach dem case,</p>
</blockquote>
<p>Nein, das kann nicht sein. Wenn du eine Variable innerhalb einer case-Anweisung<br />
deklarieren willst, dann musst du sogar einen neuen Block oeffnen.</p>
<p>mfg<br />
v R</p>
]]></description><link>https://www.c-plusplus.net/forum/post/937454</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/937454</guid><dc:creator><![CDATA[virtuell Realisticer]]></dc:creator><pubDate>Thu, 08 Dec 2005 15:36:51 GMT</pubDate></item><item><title><![CDATA[Reply to Schleife in switch Anweisung on Thu, 08 Dec 2005 15:47:16 GMT]]></title><description><![CDATA[<p>virtuell Realisticer schrieb:</p>
<blockquote>
<p>Riddick04 schrieb:</p>
<blockquote>
<p>Könnte an den geschweiften Klammern liegen nach dem case,</p>
</blockquote>
<p>Nein, das kann nicht sein. Wenn du eine Variable innerhalb einer case-Anweisung<br />
deklarieren willst, dann musst du sogar einen neuen Block oeffnen.</p>
<p>mfg<br />
v R</p>
</blockquote>
<p>Hey vituell Realisticer, danke für den Tipp. Jetzt funzt es. Hat mir ne Menge Arbeit erspart. Bis denne Shihan</p>
]]></description><link>https://www.c-plusplus.net/forum/post/937459</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/937459</guid><dc:creator><![CDATA[Shihan]]></dc:creator><pubDate>Thu, 08 Dec 2005 15:47:16 GMT</pubDate></item></channel></rss>