<?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[Ist std::cin.getline das Problem?]]></title><description><![CDATA[<p>Guten Tag,</p>
<p>der Fehler des hier aufgeführten Programms ist, dass beim &quot;Neustarten&quot; des Programmes keine Werte mehr bei cin.getline eingegeben werden können. Weiß jemand Rat? Ich habe mir auch schon den Aufbau dieses Befehls angeschaut. Liegt es eventuell daran, dass ein Flag gesetzt wird?</p>
<p>mfG Phisherman</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;windows.h&gt;
#include &lt;conio.h&gt;

using namespace std;

int main()
{   
    bool reset=true;
    char set;
    while(reset!=false)
    {
    char eingabe[100000]={0};

    char i=0;
    bool hoch;
    bool tief;
    int v;

    system(&quot;color f0&quot;);

  //eingabe[0]='\0';

    cout&lt;&lt;&quot;Beepmachine Developer Edition 1.0&quot;;

    //Programm
    cout&lt;&lt;&quot;\n\nTastenbelegung: &quot;;
    cout&lt;&lt;&quot;\np: Pause&quot;;
    cout&lt;&lt;&quot;\nl: Lange Pause&quot;;
    cout&lt;&lt;&quot;\nk: Kurze Pause&quot;;
    cout&lt;&lt;&quot;\n#: # Halbton nach oben (Gilt f&quot;&lt;&lt;char(129)&lt;&lt;&quot;r den nachstehenden Ton)&quot;;
    cout&lt;&lt;&quot;\nb: b Halbton nach unten (Gilt f&quot;&lt;&lt;char(129)&lt;&lt;&quot;r den nachstehenden Ton)&quot;;
    cout&lt;&lt;&quot;\n1: C6&quot;;
    cout&lt;&lt;&quot;\n2: D6&quot;;
    cout&lt;&lt;&quot;\n3: E6&quot;;
    cout&lt;&lt;&quot;\n4: F6&quot;;
    cout&lt;&lt;&quot;\n5: G6&quot;;
    cout&lt;&lt;&quot;\n6: A6&quot;;
    cout&lt;&lt;&quot;\n7: H6&quot;;
    cout&lt;&lt;&quot;\n8: C7&quot;;
    cout&lt;&lt;&quot;\n9: D7&quot;;
    cout&lt;&lt;&quot;\n\nHINWEIS: Sowohl die Pause als auch die Noten dauern 200ms an.&quot;;
    cout&lt;&lt;&quot;\n\nZuerst musst du die Noten (und Pausen) eintippen.&quot;;
    cout&lt;&lt;&quot;\nWenn du das getan hast, dr&quot;&lt;&lt;char(129)&lt;&lt;&quot;cke die Enter-Taste.&quot;;    
    cout&lt;&lt;&quot;\n\nGebe maximal 100.000 Zeichen ein: &quot;;

    cin.getline(eingabe, 100000);  // Diese Stell spinnt!
    cout&lt;&lt;endl&lt;&lt;endl;

    for (unsigned int z = 0; z &lt; strlen(eingabe); ++z)
       {    
        switch (eingabe[z])
        {
         case 'l': //Lange Pause
              {
               cout&lt;&lt;&quot;L. Pause &quot;;
               Sleep(400);
               break;
              }
         case '#': //halbton hoch
              {
               cout&lt;&lt;&quot;#&quot;;
               hoch=true;
               break;
              }
         case 'b': //halbton hoch
              {
               cout&lt;&lt;&quot;b&quot;;
               tief=true;
               break;
              }
         case 'k': //Kurze Pause
              {
               cout&lt;&lt;&quot;K. Pause &quot;;
               Sleep(100);
               break;
              }
         case 'p': //Pause
              {
               cout&lt;&lt;&quot;Pause &quot;;
               Sleep(200);
               break;
              }
         case '1': //C6
              {

               v=1046;
               if (hoch==true)
                 {
                             v=v+62;
                 }
               if (tief==true)
                 {
                             v=v-59;
                 }
               cout&lt;&lt;&quot;C6 &quot;;
               Beep(v, 200);
               tief=false;
               hoch=false;
               break;
              }
         case '2': //D6
              {
               v=1174;
               if (hoch==true)
                 {
                             v=v+70;
                 }
               if (tief==true)
                 {
                             v=v-66;
                 }
               cout&lt;&lt;&quot;D6 &quot;;
               Beep(v, 200);
               tief=false;
               hoch=false;
               break;
              }
         case '3': //E6
              {
               v=1318;
               if (hoch==true)
                 {
                             v=v+78;
                 }
               if (tief==true)
                 {
                             v=v-74;
                 }
               cout&lt;&lt;&quot;E6 &quot;;
               Beep(v, 200);
               tief=false;
               hoch=false;
               break;
              }
         case '4': //F6
              {
               v=1396;               
               if (hoch==true)
                 {
                             v=v+80;
                 }
               if (tief==true)
                 {
                             v=v-78;
                 }

               cout&lt;&lt;&quot;F6 &quot;;
               Beep(v, 200);
               tief=false;
               hoch=false;
               break;
              }
         case '5': //G6
              {
               v=1567;
               if (hoch==true)
                 {
                             v=v+94;
                 }
               if (tief==true)
                 {
                             v=v-88;
                 }
               cout&lt;&lt;&quot;G6 &quot;;
               Beep(v, 200);
               tief=false;
               hoch=false;
               break;
              }
         case '6': //A6
              {
               v=1760;
               if (hoch==true)
                 {
                             v=v+104;
                 }
               if (tief==true)
                 {
                             v=v-99;
                 }
               cout&lt;&lt;&quot;A6 &quot;;
               Beep(v, 200);
               tief=false;
               hoch=false;
               break;
              }
         case '7': //H6
              {
               v=1975;
               if (hoch==true)
                 {
                             v=v+118;
                 }
               if (tief==true)
                 {
                             v=v-111;
                 }
               cout&lt;&lt;&quot;H6 &quot;;
               Beep(v, 200);
               tief=false;
               hoch=false;
               break;
              }
         case '8': //C7
              {
               v=2093;
               if (hoch==true)
                 {
                             v=v+124;
                 }
               if (tief==true)
                 {
                             v=v-118;
                 }
               cout&lt;&lt;&quot;C7 &quot;;
               Beep(v, 200);
               tief=false;
               hoch=false;
               break;
              }
         case '9': //D7
              {
               v=2349;
               if (hoch==true)
                 {
                             v=v+140;
                 }
               if (tief==true)
                 {
                             v=v-132
                             ;
                 }
               cout&lt;&lt;&quot;D7 &quot;;
               Beep(v, 200);
               tief=false;
               hoch=false;
               break;
              }
         }

      }

    cout&lt;&lt;&quot;\n\nProgramm neustarten (y/n)? &quot;;
    cin&gt;&gt;set;
    cout&lt;&lt;set;
    if (set=='y')
       {
       reset=true;
       system(&quot;CLS&quot;);
       }
    else if (set=='n')      
       {
       reset=false;
       }    
    }

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/260558/ist-std-cin-getline-das-problem</link><generator>RSS for Node</generator><lastBuildDate>Mon, 07 Sep 2026 23:43:59 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/260558.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 06 Feb 2010 22:55:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Ist std::cin.getline das Problem? on Sat, 06 Feb 2010 22:55:00 GMT]]></title><description><![CDATA[<p>Guten Tag,</p>
<p>der Fehler des hier aufgeführten Programms ist, dass beim &quot;Neustarten&quot; des Programmes keine Werte mehr bei cin.getline eingegeben werden können. Weiß jemand Rat? Ich habe mir auch schon den Aufbau dieses Befehls angeschaut. Liegt es eventuell daran, dass ein Flag gesetzt wird?</p>
<p>mfG Phisherman</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;windows.h&gt;
#include &lt;conio.h&gt;

using namespace std;

int main()
{   
    bool reset=true;
    char set;
    while(reset!=false)
    {
    char eingabe[100000]={0};

    char i=0;
    bool hoch;
    bool tief;
    int v;

    system(&quot;color f0&quot;);

  //eingabe[0]='\0';

    cout&lt;&lt;&quot;Beepmachine Developer Edition 1.0&quot;;

    //Programm
    cout&lt;&lt;&quot;\n\nTastenbelegung: &quot;;
    cout&lt;&lt;&quot;\np: Pause&quot;;
    cout&lt;&lt;&quot;\nl: Lange Pause&quot;;
    cout&lt;&lt;&quot;\nk: Kurze Pause&quot;;
    cout&lt;&lt;&quot;\n#: # Halbton nach oben (Gilt f&quot;&lt;&lt;char(129)&lt;&lt;&quot;r den nachstehenden Ton)&quot;;
    cout&lt;&lt;&quot;\nb: b Halbton nach unten (Gilt f&quot;&lt;&lt;char(129)&lt;&lt;&quot;r den nachstehenden Ton)&quot;;
    cout&lt;&lt;&quot;\n1: C6&quot;;
    cout&lt;&lt;&quot;\n2: D6&quot;;
    cout&lt;&lt;&quot;\n3: E6&quot;;
    cout&lt;&lt;&quot;\n4: F6&quot;;
    cout&lt;&lt;&quot;\n5: G6&quot;;
    cout&lt;&lt;&quot;\n6: A6&quot;;
    cout&lt;&lt;&quot;\n7: H6&quot;;
    cout&lt;&lt;&quot;\n8: C7&quot;;
    cout&lt;&lt;&quot;\n9: D7&quot;;
    cout&lt;&lt;&quot;\n\nHINWEIS: Sowohl die Pause als auch die Noten dauern 200ms an.&quot;;
    cout&lt;&lt;&quot;\n\nZuerst musst du die Noten (und Pausen) eintippen.&quot;;
    cout&lt;&lt;&quot;\nWenn du das getan hast, dr&quot;&lt;&lt;char(129)&lt;&lt;&quot;cke die Enter-Taste.&quot;;    
    cout&lt;&lt;&quot;\n\nGebe maximal 100.000 Zeichen ein: &quot;;

    cin.getline(eingabe, 100000);  // Diese Stell spinnt!
    cout&lt;&lt;endl&lt;&lt;endl;

    for (unsigned int z = 0; z &lt; strlen(eingabe); ++z)
       {    
        switch (eingabe[z])
        {
         case 'l': //Lange Pause
              {
               cout&lt;&lt;&quot;L. Pause &quot;;
               Sleep(400);
               break;
              }
         case '#': //halbton hoch
              {
               cout&lt;&lt;&quot;#&quot;;
               hoch=true;
               break;
              }
         case 'b': //halbton hoch
              {
               cout&lt;&lt;&quot;b&quot;;
               tief=true;
               break;
              }
         case 'k': //Kurze Pause
              {
               cout&lt;&lt;&quot;K. Pause &quot;;
               Sleep(100);
               break;
              }
         case 'p': //Pause
              {
               cout&lt;&lt;&quot;Pause &quot;;
               Sleep(200);
               break;
              }
         case '1': //C6
              {

               v=1046;
               if (hoch==true)
                 {
                             v=v+62;
                 }
               if (tief==true)
                 {
                             v=v-59;
                 }
               cout&lt;&lt;&quot;C6 &quot;;
               Beep(v, 200);
               tief=false;
               hoch=false;
               break;
              }
         case '2': //D6
              {
               v=1174;
               if (hoch==true)
                 {
                             v=v+70;
                 }
               if (tief==true)
                 {
                             v=v-66;
                 }
               cout&lt;&lt;&quot;D6 &quot;;
               Beep(v, 200);
               tief=false;
               hoch=false;
               break;
              }
         case '3': //E6
              {
               v=1318;
               if (hoch==true)
                 {
                             v=v+78;
                 }
               if (tief==true)
                 {
                             v=v-74;
                 }
               cout&lt;&lt;&quot;E6 &quot;;
               Beep(v, 200);
               tief=false;
               hoch=false;
               break;
              }
         case '4': //F6
              {
               v=1396;               
               if (hoch==true)
                 {
                             v=v+80;
                 }
               if (tief==true)
                 {
                             v=v-78;
                 }

               cout&lt;&lt;&quot;F6 &quot;;
               Beep(v, 200);
               tief=false;
               hoch=false;
               break;
              }
         case '5': //G6
              {
               v=1567;
               if (hoch==true)
                 {
                             v=v+94;
                 }
               if (tief==true)
                 {
                             v=v-88;
                 }
               cout&lt;&lt;&quot;G6 &quot;;
               Beep(v, 200);
               tief=false;
               hoch=false;
               break;
              }
         case '6': //A6
              {
               v=1760;
               if (hoch==true)
                 {
                             v=v+104;
                 }
               if (tief==true)
                 {
                             v=v-99;
                 }
               cout&lt;&lt;&quot;A6 &quot;;
               Beep(v, 200);
               tief=false;
               hoch=false;
               break;
              }
         case '7': //H6
              {
               v=1975;
               if (hoch==true)
                 {
                             v=v+118;
                 }
               if (tief==true)
                 {
                             v=v-111;
                 }
               cout&lt;&lt;&quot;H6 &quot;;
               Beep(v, 200);
               tief=false;
               hoch=false;
               break;
              }
         case '8': //C7
              {
               v=2093;
               if (hoch==true)
                 {
                             v=v+124;
                 }
               if (tief==true)
                 {
                             v=v-118;
                 }
               cout&lt;&lt;&quot;C7 &quot;;
               Beep(v, 200);
               tief=false;
               hoch=false;
               break;
              }
         case '9': //D7
              {
               v=2349;
               if (hoch==true)
                 {
                             v=v+140;
                 }
               if (tief==true)
                 {
                             v=v-132
                             ;
                 }
               cout&lt;&lt;&quot;D7 &quot;;
               Beep(v, 200);
               tief=false;
               hoch=false;
               break;
              }
         }

      }

    cout&lt;&lt;&quot;\n\nProgramm neustarten (y/n)? &quot;;
    cin&gt;&gt;set;
    cout&lt;&lt;set;
    if (set=='y')
       {
       reset=true;
       system(&quot;CLS&quot;);
       }
    else if (set=='n')      
       {
       reset=false;
       }    
    }

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1851681</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1851681</guid><dc:creator><![CDATA[Phisherman]]></dc:creator><pubDate>Sat, 06 Feb 2010 22:55:00 GMT</pubDate></item><item><title><![CDATA[Reply to Ist std::cin.getline das Problem? on Sat, 06 Feb 2010 23:29:20 GMT]]></title><description><![CDATA[<p>Stichwort:<a href="http://cplusplus.com/reference/iostream/istream/ignore/" rel="nofollow"> <code>std::cin.ignore();</code> </a></p>
<p>Zum Codestyle:</p>
<pre><code class="language-cpp">if (hoch==true)
                 {
                             v=v+62;
                 }
               if (tief==true)
                 {
                             v=v-59;
                 }
</code></pre>
<p>lässt sich auch als:</p>
<pre><code class="language-cpp">if(hoch)
    v += 62;

else if(tief)
    v -= 59;
</code></pre>
<p>schreiben <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>Außerdem ist</p>
<pre><code class="language-cpp">for (unsigned int z = 0; z &lt; strlen(eingabe); ++z)
</code></pre>
<p>langsam, da bei jeden Schleifendurchgang <code>strlen</code> aufgerufen wird. Das geht performanter <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/1851693</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1851693</guid><dc:creator><![CDATA[eigentlich ganz einfach]]></dc:creator><pubDate>Sat, 06 Feb 2010 23:29:20 GMT</pubDate></item><item><title><![CDATA[Reply to Ist std::cin.getline das Problem? on Sat, 06 Feb 2010 23:40:41 GMT]]></title><description><![CDATA[<p>Mhm, hast Recht.<br />
Ja, das strlen kann ich, indem ich davor die Länge des CStrings überprüfe, ersetzen.<br />
Und das mit v+=62 etc. ist gut, danke! Der Code ist aber lange noch nicht fertig. Es geht mir momentan nur um das getline Problem.</p>
<p>Vielen Dank für deine Hilfe zu später Stund'.^^</p>
<p>Könntest du mir ein Beispiel für cin.ignore zeigen bzw. es gleich in den Code einbauen, dass ich es verstehe?<br />
Das Beispiel auf der Referenzseite ist zwar verständlich, jedoch weiß ich nicht, wie ich es in diesem Fall anwenden sollte. Merci</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1851696</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1851696</guid><dc:creator><![CDATA[Phisherman]]></dc:creator><pubDate>Sat, 06 Feb 2010 23:40:41 GMT</pubDate></item><item><title><![CDATA[Reply to Ist std::cin.getline das Problem? on Sat, 06 Feb 2010 23:55:50 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">// ...
cin.ignore(); // Defaultparameter sind in diesem Fall völlig ausreichend
cin.getline(eingabe, 100000);
// ...
</code></pre>
<p>sollte reichen <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/1851699</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1851699</guid><dc:creator><![CDATA[eigentlich ganz einfach]]></dc:creator><pubDate>Sat, 06 Feb 2010 23:55:50 GMT</pubDate></item><item><title><![CDATA[Reply to Ist std::cin.getline das Problem? on Sun, 07 Feb 2010 00:07:06 GMT]]></title><description><![CDATA[<p>Vielen Dank! <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/1851703</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1851703</guid><dc:creator><![CDATA[Phisherman]]></dc:creator><pubDate>Sun, 07 Feb 2010 00:07:06 GMT</pubDate></item><item><title><![CDATA[Reply to Ist std::cin.getline das Problem? on Mon, 08 Feb 2010 19:20:14 GMT]]></title><description><![CDATA[<p>Ich habe jetzt das Problem noch nicht ganz gelöst.<br />
Jetzt wird der erste Ton beim ersten Abspielen des Programms nicht wiedergegeben. Nach dem &quot;Neustarten&quot; geht es aber. Was muss ich ändern?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1852666</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1852666</guid><dc:creator><![CDATA[Phisherman]]></dc:creator><pubDate>Mon, 08 Feb 2010 19:20:14 GMT</pubDate></item></channel></rss>