<?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[Probleme nach cin]]></title><description><![CDATA[<p>Hallo.</p>
<p>Ich habe das Problem, dass nach dem Verwenden der cin-Anweisung das Programm sofort beendet und trotz getchar()-Anweisung der Bildschirm nicht erhalten bleibt.</p>
<p>Programmcode:</p>
<pre><code>#include &lt;iostream.h&gt;
main ()
{

int a, b;

cout &lt;&lt; &quot;Geben Sie die erste Zahl ein: &quot; &lt;&lt; endl;
cin &gt;&gt; a;

cout &lt;&lt; &quot;Geben Sie die zweite Zahl ein: &quot; &lt;&lt; endl;
cin &gt;&gt; b;

cout &lt;&lt; &quot;Sie haben die Zahlen &quot; &lt;&lt; a &lt;&lt; &quot; und &quot; &lt;&lt; b &lt;&lt; &quot; eingegeben.&quot; &lt;&lt; endl;
cout &lt;&lt; &quot;hallo&quot; &lt;&lt; endl;

getchar();
}
</code></pre>
<p>Nachdem ich die zweite Eingabe mit Enter bestätigt habe, wird keine der cout-Anweisungen mehr angezeigt, weil sich das Fenster sofort schließt.</p>
<p>Woran liegt das und wie kann ich das Problem verhindern?</p>
<p>Freundliche Grüße,<br />
Leader87.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/159275/probleme-nach-cin</link><generator>RSS for Node</generator><lastBuildDate>Thu, 10 Sep 2026 13:03:48 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/159275.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 13 Sep 2006 13:26:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Probleme nach cin on Wed, 13 Sep 2006 13:26:07 GMT]]></title><description><![CDATA[<p>Hallo.</p>
<p>Ich habe das Problem, dass nach dem Verwenden der cin-Anweisung das Programm sofort beendet und trotz getchar()-Anweisung der Bildschirm nicht erhalten bleibt.</p>
<p>Programmcode:</p>
<pre><code>#include &lt;iostream.h&gt;
main ()
{

int a, b;

cout &lt;&lt; &quot;Geben Sie die erste Zahl ein: &quot; &lt;&lt; endl;
cin &gt;&gt; a;

cout &lt;&lt; &quot;Geben Sie die zweite Zahl ein: &quot; &lt;&lt; endl;
cin &gt;&gt; b;

cout &lt;&lt; &quot;Sie haben die Zahlen &quot; &lt;&lt; a &lt;&lt; &quot; und &quot; &lt;&lt; b &lt;&lt; &quot; eingegeben.&quot; &lt;&lt; endl;
cout &lt;&lt; &quot;hallo&quot; &lt;&lt; endl;

getchar();
}
</code></pre>
<p>Nachdem ich die zweite Eingabe mit Enter bestätigt habe, wird keine der cout-Anweisungen mehr angezeigt, weil sich das Fenster sofort schließt.</p>
<p>Woran liegt das und wie kann ich das Problem verhindern?</p>
<p>Freundliche Grüße,<br />
Leader87.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1136656</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1136656</guid><dc:creator><![CDATA[Leader87]]></dc:creator><pubDate>Wed, 13 Sep 2006 13:26:07 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme nach cin on Wed, 13 Sep 2006 13:32:34 GMT]]></title><description><![CDATA[<p>also ganz einfach geändert</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;conio&gt;
using namespace std;
int main ()
{

int a, b;

cout &lt;&lt; &quot;Geben Sie die erste Zahl ein: &quot; &lt;&lt; endl;
cin &gt;&gt; a;

cout &lt;&lt; &quot;Geben Sie die zweite Zahl ein: &quot; &lt;&lt; endl;
cin &gt;&gt; b;

cout &lt;&lt; &quot;Sie haben die Zahlen &quot; &lt;&lt; a &lt;&lt; &quot; und &quot; &lt;&lt; b &lt;&lt; &quot; eingegeben.&quot; &lt;&lt; endl;
cout &lt;&lt; &quot;hallo&quot; &lt;&lt; endl;

getch();
return 0;
}
</code></pre>
<p>aber bitte iostream und using namespace std;</p>
<p>und es sollte eigentlich int main() heißen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1136659</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1136659</guid><dc:creator><![CDATA[ser1al]]></dc:creator><pubDate>Wed, 13 Sep 2006 13:32:34 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme nach cin on Thu, 14 Sep 2006 08:30:51 GMT]]></title><description><![CDATA[<p>Dein Problem ist recht einfach - getch() liest das nächste Zeichen aus dem Eingabepuffer, istream::operator&gt;&gt;() liest nur so weit, wie es die Eingabe interpretieren kann - also bleibt nach dem &quot;cin&gt;&gt;b;&quot; noch das Enter im Puffer zurück und wird von getch() abgefangen.</p>
<p>Zur Lösung mußt du den Puffer von Hand aufrufen, bevor du getch() verwendest (btw, in C++ solltest du lieber cin.get() nehmen) - dazu gibt es die Methode ignore().</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1137068</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1137068</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Thu, 14 Sep 2006 08:30:51 GMT</pubDate></item></channel></rss>