<?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[Überprüfen der Eingabe]]></title><description><![CDATA[<p>Hallo</p>
<p>ich bin neu im C++ BEreich und hab mich nun an die Arbeit gesetzt und ein Programm geschrieben welches mit Brüchen rechnet. Das Mathematische udn funktionelle ist soweit alles erledigt und funktionstüchtig. Nun geht es allerdings an Feintuning.<br />
Mein Problem im Moment ist, das ich gerne überprüfen würde, ob eine Eingabe ein INT Wert ist oder nicht. Allerdings habe ich keine Ahnung wie ich dies bewerkstelligen könnte.<br />
Anbei der Code der Eingabe</p>
<pre><code class="language-cpp">void bruch::eingabe()
{
  cout &lt;&lt; &quot;Zähler: &quot;;
  cin  &gt;&gt; zaehler;

  cout &lt;&lt; &quot;Nenner: &quot;;
  cin  &gt;&gt; nenner;

}
</code></pre>
<p>Lg</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/196465/überprüfen-der-eingabe</link><generator>RSS for Node</generator><lastBuildDate>Wed, 30 Sep 2026 12:27:54 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/196465.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 30 Oct 2007 08:19:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Überprüfen der Eingabe on Tue, 30 Oct 2007 08:19:34 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>ich bin neu im C++ BEreich und hab mich nun an die Arbeit gesetzt und ein Programm geschrieben welches mit Brüchen rechnet. Das Mathematische udn funktionelle ist soweit alles erledigt und funktionstüchtig. Nun geht es allerdings an Feintuning.<br />
Mein Problem im Moment ist, das ich gerne überprüfen würde, ob eine Eingabe ein INT Wert ist oder nicht. Allerdings habe ich keine Ahnung wie ich dies bewerkstelligen könnte.<br />
Anbei der Code der Eingabe</p>
<pre><code class="language-cpp">void bruch::eingabe()
{
  cout &lt;&lt; &quot;Zähler: &quot;;
  cin  &gt;&gt; zaehler;

  cout &lt;&lt; &quot;Nenner: &quot;;
  cin  &gt;&gt; nenner;

}
</code></pre>
<p>Lg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1394489</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1394489</guid><dc:creator><![CDATA[GastUser]]></dc:creator><pubDate>Tue, 30 Oct 2007 08:19:34 GMT</pubDate></item><item><title><![CDATA[Reply to Überprüfen der Eingabe on Tue, 30 Oct 2007 11:18:54 GMT]]></title><description><![CDATA[<p>Wenn du etwas in eine int-Variable einliest, ist das Ergebnis (im Erfolgsfall) per Definition ein int-Wert. Wenn da etwas kommt, was nicht als int ausgewertet werden kann, setzt der Stream das eofbit - Korrektur: das failbit - , das du auswerten und zurücksetzen kannst (und lässt die fehlerhafte Eingabe im Puffer stehen):</p>
<pre><code class="language-cpp">bool ok=false;
cout&lt;&lt;&quot;Zähler:&quot;
while(!ok)
{
  cin&gt;&gt;zahler;
  if(!cin)//Fehler aufgetreten
  {
    cin.clear();
    cin.ignore(numeric_limits&lt;streamsize&gt;::max(),'\n');
    cout&lt;&lt;&quot;Bitte keinen Müll eingeben\n&quot;;
  }
  else
    ok=true;
}
</code></pre>
<p>(das kannst du noch in eine Funktion auslagern, dann wird's kompakter)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1394514</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1394514</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Tue, 30 Oct 2007 11:18:54 GMT</pubDate></item><item><title><![CDATA[Reply to Überprüfen der Eingabe on Tue, 30 Oct 2007 10:39:57 GMT]]></title><description><![CDATA[<p>CStoll schrieb:</p>
<blockquote>
<p>Wenn du etwas in eine int-Variable einliest, ist das Ergebnis (im Erfolgsfall) per Definition ein int-Wert. Wenn da etwas kommt, was nicht als int ausgewertet werden kann, setzt der Stream das eofbit</p>
</blockquote>
<p>Ist es nicht eher das failbit? (meiner Referenz zufolge zumindest)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1394582</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1394582</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Tue, 30 Oct 2007 10:39:57 GMT</pubDate></item><item><title><![CDATA[Reply to Überprüfen der Eingabe on Tue, 30 Oct 2007 11:18:01 GMT]]></title><description><![CDATA[<p>Punkt für dich - das kommt davon, wenn man schneller schreibt als denkt <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/1394607</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1394607</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Tue, 30 Oct 2007 11:18:01 GMT</pubDate></item></channel></rss>