<?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[Hilfe für Neulinge]]></title><description><![CDATA[<p>Ich hab n kleines Prb:</p>
<p>Ich habe mit der Hilfe ein kleines &quot;Programm&quot; geschrieben:</p>
<p>#include &lt;iostream&gt;<br />
using namespace std;</p>
<p>int main()<br />
{<br />
cout&lt;&lt;&quot;Bitte geben Sie eine Zahl ein\n&quot;;<br />
int a;<br />
cin&gt;&gt;a;<br />
cout&lt;&lt;&quot;Bitte geben Sie noch eine Zahl ein\n&quot;;<br />
int b;<br />
cin&gt;&gt;b;</p>
<p>if(a==b)<br />
{<br />
cout&lt;&lt;&quot;Beide Zahlen sind gleich&quot;;<br />
}<br />
if(a&lt;b)<br />
{<br />
cout&lt;&lt;a&lt;&lt;&quot; ist kleiner als &quot;&lt;&lt;b;<br />
}<br />
if(a&gt;b)<br />
{<br />
cout&lt;&lt;a&lt;&lt;&quot; ist größer als &quot;&lt;&lt;b;<br />
}<br />
cout&lt;&lt;&quot;\n&quot;;<br />
cin.get();<br />
}<br />
Aber wenn ich dann die Zahlen eingeben habe und ein 3tes mal Enter gedrückt habe<br />
um die Lösung zu erhalten, schließt das Fenster.....<br />
Wie kannn ich es so machen, dass meine Lösung angezeigt wird und ich erst ein 4tes mal Enter drücken muss, dass sich mein Fenster schließt....</p>
<p>Ich danke für jede Antwort....</p>
<p>Gruß<br />
Special TerrorMen....^^</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/186626/hilfe-für-neulinge</link><generator>RSS for Node</generator><lastBuildDate>Thu, 24 Sep 2026 15:11:08 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/186626.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 10 Jul 2007 19:39:52 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Hilfe für Neulinge on Tue, 10 Jul 2007 19:39:52 GMT]]></title><description><![CDATA[<p>Ich hab n kleines Prb:</p>
<p>Ich habe mit der Hilfe ein kleines &quot;Programm&quot; geschrieben:</p>
<p>#include &lt;iostream&gt;<br />
using namespace std;</p>
<p>int main()<br />
{<br />
cout&lt;&lt;&quot;Bitte geben Sie eine Zahl ein\n&quot;;<br />
int a;<br />
cin&gt;&gt;a;<br />
cout&lt;&lt;&quot;Bitte geben Sie noch eine Zahl ein\n&quot;;<br />
int b;<br />
cin&gt;&gt;b;</p>
<p>if(a==b)<br />
{<br />
cout&lt;&lt;&quot;Beide Zahlen sind gleich&quot;;<br />
}<br />
if(a&lt;b)<br />
{<br />
cout&lt;&lt;a&lt;&lt;&quot; ist kleiner als &quot;&lt;&lt;b;<br />
}<br />
if(a&gt;b)<br />
{<br />
cout&lt;&lt;a&lt;&lt;&quot; ist größer als &quot;&lt;&lt;b;<br />
}<br />
cout&lt;&lt;&quot;\n&quot;;<br />
cin.get();<br />
}<br />
Aber wenn ich dann die Zahlen eingeben habe und ein 3tes mal Enter gedrückt habe<br />
um die Lösung zu erhalten, schließt das Fenster.....<br />
Wie kannn ich es so machen, dass meine Lösung angezeigt wird und ich erst ein 4tes mal Enter drücken muss, dass sich mein Fenster schließt....</p>
<p>Ich danke für jede Antwort....</p>
<p>Gruß<br />
Special TerrorMen....^^</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1322608</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1322608</guid><dc:creator><![CDATA[Special TerrorMen*]]></dc:creator><pubDate>Tue, 10 Jul 2007 19:39:52 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe für Neulinge on Tue, 10 Jul 2007 19:53:11 GMT]]></title><description><![CDATA[<p>Tut mir leid, ich kapier nicht wirklich was du willst.</p>
<p>Durch das cin.get() bleibt doch das Fenster offen und du kannst die Lösung sehen, oder nicht?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1322613</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1322613</guid><dc:creator><![CDATA[krischan111]]></dc:creator><pubDate>Tue, 10 Jul 2007 19:53:11 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe für Neulinge on Tue, 10 Jul 2007 21:29:05 GMT]]></title><description><![CDATA[<p>Dein Programm ertwartet doch nur 2 Eingaben. Vor der Lösung ist kein Enter erforderlich.</p>
<p>Schau Dich mal ein wenig im C++ Bereich um (Eventuell wars auch im Konsolenforum -&gt; FAQ) , das Thema Fenster schliesst sich einfach oft behandelt. (Letzendlich ist es aber ein Problem der Konsole, nicht des Programmes.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1322662</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1322662</guid><dc:creator><![CDATA[Knuddlbaer]]></dc:creator><pubDate>Tue, 10 Jul 2007 21:29:05 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe für Neulinge on Tue, 10 Jul 2007 23:57:48 GMT]]></title><description><![CDATA[<p>Ich habs geschafft....</p>
<p>Hier einmal meine lösung, wenn ihr wollt koennt ihr ja auch noch ne andere Lösung hinschreiben</p>
<p>#include &lt;iostream&gt;<br />
using namespace std;</p>
<p>int main()<br />
{<br />
cout&lt;&lt;&quot;Bitte geben Sie eine Zahl ein\n&quot;;<br />
int a;<br />
cin&gt;&gt;a;<br />
cout&lt;&lt;&quot;Bitte geben Sie noch eine Zahl ein\n&quot;;<br />
int b;<br />
cin&gt;&gt;b;<br />
cin.get(); //HIER LAG DER FEHLER //</p>
<p>if(a==b)<br />
{<br />
cout&lt;&lt;&quot;Beide Zahlen sind gleich&quot;;<br />
}<br />
else if(a&lt;b)<br />
{<br />
cout&lt;&lt;a&lt;&lt;&quot; ist kleiner als &quot;&lt;&lt;b;<br />
}<br />
else<br />
{<br />
cout&lt;&lt;a&lt;&lt;&quot; ist größer als &quot;&lt;&lt;b;</p>
<p>}<br />
cout&lt;&lt;&quot;\n&quot;;<br />
cin.get();</p>
<p>}</p>
<p>......<br />
Na wie bin ich gut nähh??? ;))</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1322688</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1322688</guid><dc:creator><![CDATA[Special TerrorMen*]]></dc:creator><pubDate>Tue, 10 Jul 2007 23:57:48 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe für Neulinge on Thu, 12 Jul 2007 15:23:20 GMT]]></title><description><![CDATA[<p>Super!</p>
<p>Normal lässt man ein Konsolenprogramm in einer while Schleife ablaufen...</p>
<p>Btw: Falsches Forum. Poste nächste mal unter C++, nicht C++/CLI</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1323996</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1323996</guid><dc:creator><![CDATA[Dappeljuh]]></dc:creator><pubDate>Thu, 12 Jul 2007 15:23:20 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe für Neulinge on Thu, 12 Jul 2007 17:19:57 GMT]]></title><description><![CDATA[<p>Dieser Thread wurde von Moderator/in <a href="http://www.c-plusplus.net/forum/profile-var-mode-is-viewprofile-and-u-is-18363.html" rel="nofollow">Jochen Kalmbach</a> aus dem Forum <a href="http://www.c-plusplus.net/forum/viewforum-var-f-is-58.html" rel="nofollow">C++/CLI mit .NET</a> in das Forum <a href="http://www.c-plusplus.net/forum/viewforum-var-f-is-15.html" rel="nofollow">C++</a> verschoben.</p>
<p>Im Zweifelsfall bitte auch folgende Hinweise beachten:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-39405.html" rel="nofollow">C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?</a></p>
<p><em>Dieses Posting wurde automatisch erzeugt.</em></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1324066</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1324066</guid><dc:creator><![CDATA[C++ Forumbot]]></dc:creator><pubDate>Thu, 12 Jul 2007 17:19:57 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe für Neulinge on Thu, 12 Jul 2007 19:26:11 GMT]]></title><description><![CDATA[<p>Dappeljuh schrieb:</p>
<blockquote>
<p>Super!</p>
<p>Normal lässt man ein Konsolenprogramm in einer while Schleife ablaufen...</p>
</blockquote>
<p>wozu willst du bei sonem programm ne while schleife benutzen? eine schleife benutzt man wenn das programm eine bestimmte anzahl von durchläufen haben soll, aber das heisst noch lange nicht das bei jedem consolenprogramm eine schleufe zum einsatz kommt. wie wärs wenn du mal lernst was ne schleife ist?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1324120</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1324120</guid><dc:creator><![CDATA[Thundereye]]></dc:creator><pubDate>Thu, 12 Jul 2007 19:26:11 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe für Neulinge on Fri, 13 Jul 2007 08:10:46 GMT]]></title><description><![CDATA[<blockquote>
<p>wie wärs wenn du mal lernst was ne schleife ist?</p>
</blockquote>
<p>Sonst gehts Dir aber gut?</p>
<p>Da die Anwendung nach dem Ende der Main Funktion beendet ist, ist es meiner Meinung nach das sinnvollste, nach dem Eintritt in diese eine while Schleife einzubauen und bei jedem Durchlauf die Abbruchbedingung neu zu checken...</p>
<p>So hab ichs zumindest immer gelöst...</p>
<p>Was wäre denn Deiner Meinung nach die ultimative Lösung?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1324381</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1324381</guid><dc:creator><![CDATA[Dappeljuh]]></dc:creator><pubDate>Fri, 13 Jul 2007 08:10:46 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe für Neulinge on Fri, 13 Jul 2007 08:13:09 GMT]]></title><description><![CDATA[<p>es ging doch bei dem programm nur um einen vergleich...</p>
<p>eine schleife wäre imho nur sinnvoll, wenn mehrere vergleiche realisiert werden sollen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1324385</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1324385</guid><dc:creator><![CDATA[hokage]]></dc:creator><pubDate>Fri, 13 Jul 2007 08:13:09 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe für Neulinge on Fri, 13 Jul 2007 08:14:15 GMT]]></title><description><![CDATA[<p>Wenn das Programm ohnehin nur einmal durchlaufen soll reicht ein std::cin.get() oder irgendwas ähnliches was auf einen Tastendruck oder eine Eingabe wartet um das Fenster offen zu halten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1324386</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1324386</guid><dc:creator><![CDATA[David_pb]]></dc:creator><pubDate>Fri, 13 Jul 2007 08:14:15 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe für Neulinge on Fri, 13 Jul 2007 08:18:26 GMT]]></title><description><![CDATA[<p>ich mach immer 2x cin.get() xD</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1324391</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1324391</guid><dc:creator><![CDATA[hokage]]></dc:creator><pubDate>Fri, 13 Jul 2007 08:18:26 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe für Neulinge on Fri, 13 Jul 2007 08:19:39 GMT]]></title><description><![CDATA[<p>Sollte das jetzt ein Witz sein? Wenn nein, wieso?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1324392</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1324392</guid><dc:creator><![CDATA[David_pb]]></dc:creator><pubDate>Fri, 13 Jul 2007 08:19:39 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe für Neulinge on Fri, 13 Jul 2007 08:23:49 GMT]]></title><description><![CDATA[<p>hab ich mir irgendwie angewöhnt xD<br />
is mir sicherer <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="😛"
    /></p>
<p>ne, das war kein witz</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1324398</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1324398</guid><dc:creator><![CDATA[hokage]]></dc:creator><pubDate>Fri, 13 Jul 2007 08:23:49 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe für Neulinge on Fri, 13 Jul 2007 08:26:07 GMT]]></title><description><![CDATA[<p>Ahja, sehr sinnvoll...</p>
<p>Machs doch dann so:</p>
<pre><code class="language-cpp">for ( int i = 0; i &lt; 150; ++i )
{
  std::cin.clear();
  std::cin.ignore( std::numeric_limits&lt; std::streamsize &gt;::max(), '\n' );
  std::cin.get();
}
</code></pre>
<p>Oder totsicher (ohne jegliche Rückkehr):</p>
<pre><code class="language-cpp">for ( ;; );
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1324404</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1324404</guid><dc:creator><![CDATA[David_pb]]></dc:creator><pubDate>Fri, 13 Jul 2007 08:26:07 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe für Neulinge on Fri, 13 Jul 2007 10:00:49 GMT]]></title><description><![CDATA[<p>Wohin son Post doch führen kann <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="😃"
    /> <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="😃"
    /> <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>
<p>Okay, sofern das Programm nur einmal durchlaufen soll, ist das ja alles i.O.!</p>
<p>Ich find halt nur das es zum guten Stil gehört, ein Programm erst dann zu beenden, wenn der Benutzer es will...</p>
<p>MFG<br />
Dapp</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1324506</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1324506</guid><dc:creator><![CDATA[Dappeljuh]]></dc:creator><pubDate>Fri, 13 Jul 2007 10:00:49 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe für Neulinge on Fri, 13 Jul 2007 10:45:29 GMT]]></title><description><![CDATA[<p>xD</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1324555</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1324555</guid><dc:creator><![CDATA[hokage]]></dc:creator><pubDate>Fri, 13 Jul 2007 10:45:29 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe für Neulinge on Fri, 13 Jul 2007 21:01:59 GMT]]></title><description><![CDATA[<p>hokage schrieb:</p>
<blockquote>
<p>ich mach immer 2x cin.get() xD</p>
</blockquote>
<p>Das ist Unverständnis von IOstreams. Der OP liefert ein Beispiel für das Mischen von formatiertem Input (operator&gt;&gt;) mit unformatiertem (get). Diese beiden Arten verhalten sich unterschiedlich. Das ignore ist eine denkbar schlechte Lösung, die die Symptome tötet, aber das eigentlich Problem wird nicht erkannt (und neue geschaffen).</p>
<p>operator&gt;&gt;(int&amp;) liest alle Zeichen der Zahl ein und hört sofort danach auf, wenn das nächste Zeichen keine Zahl ist (per Lookahead). Sprich, wenn du nach der Zahl Enter gedrückt hast, bleibt das \n (und immer nur <em>ein \n</em> - ein eventuelles #13#10 unter Windows wird durch das Code Conversion Facet des Streams in \n umgewandelt) im Stream stehen. Und dieses wird mit dem nächsten cin.get dann gelesen, was das Programm sich dann auch beenden lässt.</p>
<p>In diesem Fall würde tatsächlich ein zweimaliges cin.get es tun. Allerdings nicht immer, denn es hängt immer davon ab, was man mit dem Stream gemacht hat (z.B. formatierten Input mit unformatiertem gemischt), deshalb ist auch das kein Allheilmittel und man muss selbst nachdenken.</p>
<p>Nachtrag:<br />
Quark... auch zweimal cin.get muss nicht helfen. Wenn du 567ABC\n eingegeben hast, wird 567 als Zahl interpretiert (bevor jemand fragt - ja, so arbeitet formatierter Input) und der Rest (ABC\n) bleibt im Stream. Eine sichere Lösung gibt es nicht. Selbst das ignore hat keine 100% Garantie auf Erfolg, da nur alle Zeichen im Buffer gelöscht werden, aber weitere aus der Pipe kommen können - von dem möglicherweise sinnvollen Inhalt im Stream abgesehen, den man damit killt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1324975</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1324975</guid><dc:creator><![CDATA[7H3 N4C3R]]></dc:creator><pubDate>Fri, 13 Jul 2007 21:01:59 GMT</pubDate></item></channel></rss>