<?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[Nur INT zulassen]]></title><description><![CDATA[<p>Tag.<br />
Hab gestern einen einfachen Taschenrechner programmiert, aber komme an paar stellen nicht weiter.</p>
<p>Z.b. wenn man statt eine Zahl einen Buchstaben eingibt, schließt sich das Programm.<br />
Ich hoffe ihr könnt mir weiterhelfe.</p>
<pre><code class="language-cpp">#include &lt;iostream.h&gt;
int main()
{
int x, y, z;
char ende;
char funktion;

do
{
        cout &lt;&lt; &quot;Addition: +\nSubtraktion: -\n\nRechnungsart: &quot;;
        cin &gt;&gt; funktion;
        switch (funktion)
        {
                case '+':
                cout &lt;&lt; &quot;\nErste Zahl: &quot;;
                cin &gt;&gt; x;
                cout &lt;&lt; &quot;\nZweite Zahl: &quot;;
                cin &gt;&gt; y;
                z = x + y;
                getchar();
                cout &lt;&lt; &quot;\nErgebnis: &quot; &lt;&lt; z &lt;&lt; endl;
                break;

                case '-':
                cout &lt;&lt; &quot;Erste Zahl: &quot;;
                cin &gt;&gt; x;
                cout &lt;&lt; &quot;\nZweite Zahl: &quot;;
                cin &gt;&gt; y;
                z = x - y;
                getchar();
                cout &lt;&lt; &quot;\nErgebnis: &quot;&lt;&lt; z &lt;&lt; endl;
                getchar();
                break;

                default:
                cout &lt;&lt; &quot;FALSCH&quot;;
                getchar();
                break;
        }
        cout &lt;&lt; &quot;\nWenn Sie weiterrechnen wollen tippen Sie auf E: &quot;;
        cin &gt;&gt; ende;
        getchar();
}
while (ende == 'e');
return 0;
}
</code></pre>
<p>MfG<br />
<strong>T</strong>echnology</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/144634/nur-int-zulassen</link><generator>RSS for Node</generator><lastBuildDate>Wed, 02 Sep 2026 20:39:32 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/144634.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 19 Apr 2006 21:52:19 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Nur INT zulassen on Wed, 19 Apr 2006 21:52:19 GMT]]></title><description><![CDATA[<p>Tag.<br />
Hab gestern einen einfachen Taschenrechner programmiert, aber komme an paar stellen nicht weiter.</p>
<p>Z.b. wenn man statt eine Zahl einen Buchstaben eingibt, schließt sich das Programm.<br />
Ich hoffe ihr könnt mir weiterhelfe.</p>
<pre><code class="language-cpp">#include &lt;iostream.h&gt;
int main()
{
int x, y, z;
char ende;
char funktion;

do
{
        cout &lt;&lt; &quot;Addition: +\nSubtraktion: -\n\nRechnungsart: &quot;;
        cin &gt;&gt; funktion;
        switch (funktion)
        {
                case '+':
                cout &lt;&lt; &quot;\nErste Zahl: &quot;;
                cin &gt;&gt; x;
                cout &lt;&lt; &quot;\nZweite Zahl: &quot;;
                cin &gt;&gt; y;
                z = x + y;
                getchar();
                cout &lt;&lt; &quot;\nErgebnis: &quot; &lt;&lt; z &lt;&lt; endl;
                break;

                case '-':
                cout &lt;&lt; &quot;Erste Zahl: &quot;;
                cin &gt;&gt; x;
                cout &lt;&lt; &quot;\nZweite Zahl: &quot;;
                cin &gt;&gt; y;
                z = x - y;
                getchar();
                cout &lt;&lt; &quot;\nErgebnis: &quot;&lt;&lt; z &lt;&lt; endl;
                getchar();
                break;

                default:
                cout &lt;&lt; &quot;FALSCH&quot;;
                getchar();
                break;
        }
        cout &lt;&lt; &quot;\nWenn Sie weiterrechnen wollen tippen Sie auf E: &quot;;
        cin &gt;&gt; ende;
        getchar();
}
while (ende == 'e');
return 0;
}
</code></pre>
<p>MfG<br />
<strong>T</strong>echnology</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1040953</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1040953</guid><dc:creator><![CDATA[technology]]></dc:creator><pubDate>Wed, 19 Apr 2006 21:52:19 GMT</pubDate></item><item><title><![CDATA[Reply to Nur INT zulassen on Wed, 19 Apr 2006 23:33:36 GMT]]></title><description><![CDATA[<p>iostream.h ist kein standard c++. naja, egal <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f921.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--clown_face"
      title=":clown:"
      alt="🤡"
    /></p>
<p>!google iostream failbit <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/27a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--right_arrow"
      title=":arrow_right:"
      alt="➡"
    /> wenn etwas schief gegangen ist, kann man das an cin.fail() erkennen. mit clear() kann man den zustand wiederr zurpcksetzen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1040991</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1040991</guid><dc:creator><![CDATA[Gideon]]></dc:creator><pubDate>Wed, 19 Apr 2006 23:33:36 GMT</pubDate></item><item><title><![CDATA[Reply to Nur INT zulassen on Wed, 19 Apr 2006 23:52:36 GMT]]></title><description><![CDATA[<blockquote>
<p>iostream.h ist kein standard c++. naja, egal</p>
</blockquote>
<p>Nicht, nein?<br />
Also alle Dateien ohne #include sind Standard!?!???<br />
Sagen wir es mal so: Das ist Quatsch!</p>
<p>WAS ZUR HÖLLE IST DENN DANN STANDARD?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1040998</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1040998</guid><dc:creator><![CDATA[perser]]></dc:creator><pubDate>Wed, 19 Apr 2006 23:52:36 GMT</pubDate></item><item><title><![CDATA[Reply to Nur INT zulassen on Thu, 20 Apr 2006 00:21:49 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;iostream&gt;
</code></pre>
<p>Das ist Standard</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1041002</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1041002</guid><dc:creator><![CDATA[Allwissender]]></dc:creator><pubDate>Thu, 20 Apr 2006 00:21:49 GMT</pubDate></item><item><title><![CDATA[Reply to Nur INT zulassen on Thu, 20 Apr 2006 00:24:30 GMT]]></title><description><![CDATA[<p>es geht um das<br />
#include &lt;iostream**.h**&gt;<br />
das .h einfach weglassen. die funktionen/klassen befinden sich dann im namespace std.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1041004</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1041004</guid><dc:creator><![CDATA[cin]]></dc:creator><pubDate>Thu, 20 Apr 2006 00:24:30 GMT</pubDate></item><item><title><![CDATA[Reply to Nur INT zulassen on Thu, 20 Apr 2006 00:39:36 GMT]]></title><description><![CDATA[<p>Das .h gibt es seit C98 nicht mehr.</p>
<p>Liste:</p>
<pre><code>-bash-3.00$ ls /usr/include/g++/
FlexLexer.h                cstring                    locale
algorithm                  ctime                      map
backward                   cwchar                     memory
bits                       cwctype                    new
bitset                     cxxabi.h                   numeric
cassert                    deque                      ostream
cctype                     exception                  queue
cerrno                     exception_defines.h        set
cfloat                     ext                        sstream
ciso646                    fstream                    stack
climits                    functional                 std
clocale                    i386-unknown-openbsd3.8    stdexcept
cmath                      iomanip                    streambuf
complex                    ios                        string
csetjmp                    iosfwd                     typeinfo
csignal                    iostream                   utility
cstdarg                    istream                    valarray
cstddef                    iterator                   vector
cstdio                     limits
cstdlib                    list
-bash-3.00$
</code></pre>
<p>Gg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1041008</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1041008</guid><dc:creator><![CDATA[xGhost]]></dc:creator><pubDate>Thu, 20 Apr 2006 00:39:36 GMT</pubDate></item><item><title><![CDATA[Reply to Nur INT zulassen on Fri, 21 Apr 2006 17:41:21 GMT]]></title><description><![CDATA[<p>ist doch egal oder ob ich nur &lt;iostream&gt; oder &lt;iostream.h&gt; schreib.</p>
<p>mit .h spare ich mir die zeile mit namespace std und so..</p>
<p>und wer kann mir mit meinem problem weiterhelfen?</p>
<p>MfG<br />
<strong>T</strong>echnology</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1042150</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1042150</guid><dc:creator><![CDATA[technilogy]]></dc:creator><pubDate>Fri, 21 Apr 2006 17:41:21 GMT</pubDate></item><item><title><![CDATA[Reply to Nur INT zulassen on Fri, 21 Apr 2006 17:55:50 GMT]]></title><description><![CDATA[<p>Witzbold. Das mit den Namespaces hat schon seinen Sinn, genauso wie die &quot;neuen&quot; Header. Außerdem ist programmieren nach dem Standard Pflicht wenn du im <strong>Standard</strong>-C++ Forum fragst. Hat dir Gideons Beitrag nicht geholfen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1042162</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1042162</guid><dc:creator><![CDATA[.filmor]]></dc:creator><pubDate>Fri, 21 Apr 2006 17:55:50 GMT</pubDate></item><item><title><![CDATA[Reply to Nur INT zulassen on Fri, 21 Apr 2006 19:07:38 GMT]]></title><description><![CDATA[<p>technilogy schrieb:</p>
<blockquote>
<p>ist doch egal oder ob ich nur &lt;iostream&gt; oder &lt;iostream.h&gt; schreib.</p>
<p>mit .h spare ich mir die zeile mit namespace std und so..</p>
</blockquote>
<p>Es gibt noch mehr unterschiede als nur den anderen Namen. Die neuen Header sind besser, glaub uns.</p>
<p>Zu deinem Problem: Gideon hat die Lösung doch schon gesagt:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;

int main() {
    using namespace std;
    int a;
    cin &gt;&gt; a;
    if(cin.fail()) {
        cout &lt;&lt; &quot;Das ist keine Zahl du Trottel!&quot; &lt;&lt; endl;
    }
    return 0;
}
</code></pre>
<p>mfg.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1042190</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1042190</guid><dc:creator><![CDATA[joomoo]]></dc:creator><pubDate>Fri, 21 Apr 2006 19:07:38 GMT</pubDate></item><item><title><![CDATA[Reply to Nur INT zulassen on Fri, 21 Apr 2006 21:25:41 GMT]]></title><description><![CDATA[<p>Nur der Vollstaendigkeit halber;</p>
<p>Du kannst auch einfach string.h includieren, dann in einen string einlesen und anschliessend den string in ein int casten. So bekommst du den Input auf jeden Fall. Zum Casten kannst du einfach Stringstreams benutzen. Dazu sstream.h includieren.</p>
<p>Viel Spass, hau rein, gr33tz</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1042278</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1042278</guid><dc:creator><![CDATA[rul00000000r]]></dc:creator><pubDate>Fri, 21 Apr 2006 21:25:41 GMT</pubDate></item><item><title><![CDATA[Reply to Nur INT zulassen on Fri, 21 Apr 2006 22:53:21 GMT]]></title><description><![CDATA[<p>perser schrieb:</p>
<blockquote>
<p>WAS ZUR HÖLLE IST DENN DANN STANDARD?</p>
</blockquote>
<p>ISO/IEC 14882:2003(E) <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>technilogy schrieb:</p>
<blockquote>
<p>ist doch egal oder ob ich nur &lt;iostream&gt; oder &lt;iostream.h&gt; schreib.</p>
</blockquote>
<p>Nein, ist es nicht. Punkt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1042305</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1042305</guid><dc:creator><![CDATA[groovemaster]]></dc:creator><pubDate>Fri, 21 Apr 2006 22:53:21 GMT</pubDate></item><item><title><![CDATA[Reply to Nur INT zulassen on Sat, 22 Apr 2006 08:13:38 GMT]]></title><description><![CDATA[<p>rul00000000r schrieb:</p>
<blockquote>
<p>Du kannst auch einfach string.h includieren</p>
</blockquote>
<p>Wenn, dann doch bitte &lt;string&gt; (ohne .h) - die &lt;string.h&gt; ist ein Erbe von C und enthält die Verarbeitungsfunktionen für C-Strings (char*): strcmp(), strcpy(),...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1042381</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1042381</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Sat, 22 Apr 2006 08:13:38 GMT</pubDate></item><item><title><![CDATA[Reply to Nur INT zulassen on Sat, 22 Apr 2006 08:14:34 GMT]]></title><description><![CDATA[<p>Bitte lass mich auch zu.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1042382</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1042382</guid><dc:creator><![CDATA[LONG]]></dc:creator><pubDate>Sat, 22 Apr 2006 08:14:34 GMT</pubDate></item><item><title><![CDATA[Reply to Nur INT zulassen on Sun, 23 Apr 2006 13:32:09 GMT]]></title><description><![CDATA[<p>Hallo.</p>
<p>Ich weiss, dass ich als Noob euch nerve. Aber was solls ^^</p>
<p>Zu meinem Anfänger Taschenrechnerprogramm habe ich vieles versucht. Aber leider habe ich kein Endprodukt.<br />
In meinem ANSI C++ Buch von Markt &amp; Technik habe ich bei den Schleifen nachgeschaut. Mit IF habe ich Versuche gemacht. Aber habs nicht geschafft.<br />
Mit while habe ich es auch versucht. Auch mit do - while. Aber wenn ich einen String eingebe entsteht eine Endlosschleife.</p>
<p>Ich komm leider nicht weiter.</p>
<p>Auf der ersten Seite von diesem Thema findet ihr den Code von meinem Taschenrechner.<br />
Ich möchte nur, dass bei Eingaben von String eine Meldung kommt und das Programm wiederholt wird. Also wieder die Erste Zahl zum Addieren verlangt.</p>
<p>mit cin.fail() habe ich es auch nicht geschafft. Weil ich bei meinem Programm nicht nur einmal <strong>cin &gt;&gt;</strong> verwende, sondern öfterst. Ich glaub deswegen funzt es nicht.</p>
<p>Dann habe ich mit cin.fail() versucht:</p>
<pre><code class="language-cpp">int a,b;
cin &gt;&gt; a;
if (cin.a.fail()) {
cout &lt;&lt; &quot;Fehler&quot; endl;
} else { // else damit er die zweite Zahl zum addieren eingibt
cin &gt;&gt; b;
if (cin.b.fail()) {
cout &lt;&lt; &quot;Fehler&quot; endl;
}
</code></pre>
<p>So habe ich es auch versucht. Vielleicht würds ja gehn. Aber ging auch nicht.</p>
<p>Paar Fragen hätte ich noch <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<p>Wie ich schon oben erwähnt habe habe ich ein Buch von Markt und Technik (ANSI C++)<br />
Bei den Programmen wird über <strong>#include &lt;iostream.h&gt;</strong> verwendet.<br />
Und wieso verwendet ihr nur <strong>#include &lt;iostream&gt;</strong>? Ich verstehe den Unterschied leider noch immer nicht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /><br />
Und bei Ausgaben ist es glaube ich egal ob ich</p>
<pre><code class="language-cpp">cout &lt;&lt; &quot;Test&quot; endl;
// oder
cout &lt;&lt; &quot;Test&quot;;
</code></pre>
<p>verwende oder?</p>
<p>Danke im Voraus.</p>
<p>MfG<br />
<strong>T</strong>echnology</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1043292</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1043292</guid><dc:creator><![CDATA[technology]]></dc:creator><pubDate>Sun, 23 Apr 2006 13:32:09 GMT</pubDate></item><item><title><![CDATA[Reply to Nur INT zulassen on Sun, 23 Apr 2006 13:52:19 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">int a,b;
cin &gt;&gt; a;
if (cin.a.fail()) {
cout &lt;&lt; &quot;Fehler&quot; endl;
} else { // else damit er die zweite Zahl zum addieren eingibt
cin &gt;&gt; b;
if (cin.b.fail()) {
cout &lt;&lt; &quot;Fehler&quot; endl;
}
</code></pre>
<p>Vielleicht hast du die auch nur vergessen mit einzutippen, aber am Ende fehlt noch eine geschweifte Klammer. Ich kenne mich mit der Methode fail() nicht aus, aber eigentlich müsste sich diese Methode immer auf das letzte cin beziehen. Also einfach nur cin.fail() und nicht cin.a.fail().</p>
<pre><code class="language-cpp">cout &lt;&lt; &quot;Test&quot; endl;
// oder
cout &lt;&lt; &quot;Test&quot;;
</code></pre>
<p>Kommt drauf an: Wenn du nach der letzten Variante ein neues cout-Objekt einfügst, würde der Text aneinander gereiht werden:</p>
<pre><code class="language-cpp">cout &lt;&lt; &quot;Text1&quot;;
cout &lt;&lt; &quot;Text2&quot;;
</code></pre>
<p>würde die Ausgabe</p>
<pre><code>Text1Text2
</code></pre>
<p>ergeben. Hingegen</p>
<pre><code class="language-cpp">cout &quot;Text1&quot; &lt;&lt; endl;
cout &lt;&lt; &quot;Text2&quot; &lt;&lt; endl;
</code></pre>
<p>die Ausgabe</p>
<pre><code>Text1
Text2
</code></pre>
<p>ergeben würde. Du siehst: endl beendet die Zeile (du könntest auch stattdessen \n in den String mitreinnehmen).</p>
<p>Mfg Ominion</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1043307</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1043307</guid><dc:creator><![CDATA[Ominion]]></dc:creator><pubDate>Sun, 23 Apr 2006 13:52:19 GMT</pubDate></item><item><title><![CDATA[Reply to Nur INT zulassen on Sun, 23 Apr 2006 14:04:57 GMT]]></title><description><![CDATA[<p>Schau dir das an <a href="http://www.parashift.com/c++-faq-lite/input-output.html#faq-15.3" rel="nofollow">http://www.parashift.com/c++-faq-lite/input-output.html#faq-15.3</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1043316</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1043316</guid><dc:creator><![CDATA[Dr. Prof]]></dc:creator><pubDate>Sun, 23 Apr 2006 14:04:57 GMT</pubDate></item><item><title><![CDATA[Reply to Nur INT zulassen on Sun, 23 Apr 2006 17:56:08 GMT]]></title><description><![CDATA[<p>Dr. Prof schrieb:</p>
<blockquote>
<p>Schau dir das an <a href="http://www.parashift.com/c++-faq-lite/input-output.html#faq-15.3" rel="nofollow">http://www.parashift.com/c++-faq-lite/input-output.html#faq-15.3</a></p>
</blockquote>
<p>Dr.Prof vielen Dank für den Link. Hat mir sehr geholfen.</p>
<p>Endlich habe ich es Dank euch geschafft.<br />
Hier mein fertiger Code.</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
int main()
{
using namespace std;
int x, y, z;
char ende, funktion;

do
{
        cout &lt;&lt; &quot;Addition: +\nSubtraktion: -\n\nRechnungsart: &quot;;
        cin &gt;&gt; funktion;
        switch (funktion)
        {
                case '+':
                while ((cout &lt;&lt; &quot;Erste Zahl: &quot;) &amp;&amp; !(cin &gt;&gt; x)) {
                        cout &lt;&lt; &quot;Das ist keine Zahl! &quot;;
                        cin.clear();
                        cin.ignore(numeric_limits&lt;streamsize&gt;::max(), '\n');
                }
                while ((cout &lt;&lt; &quot;Zweite Zahl: &quot;) &amp;&amp; !(cin &gt;&gt; y)) {
                        cout &lt;&lt; &quot;Das ist keine Zahl! &quot;;
                        cin.clear();
                        cin.ignore(numeric_limits&lt;streamsize&gt;::max(), '\n');
                }
                z = x + y;
                cout &lt;&lt; &quot;\nErgebnis: &quot;&lt;&lt; z &lt;&lt; endl;
                break;

                case '-':
                while ((cout &lt;&lt; &quot;Erste Zahl: &quot;) &amp;&amp; !(cin &gt;&gt; x)) {
                        cout &lt;&lt; &quot;Das ist keine Zahl. &quot;;
                        cin.clear();
                        cin.ignore(numeric_limits&lt;streamsize&gt;::max(), '\n');
                }

                while ((cout &lt;&lt; &quot;Zweite Zahl: &quot;) &amp;&amp; !(cin &gt;&gt; y)) {
                        cout &lt;&lt; &quot;Das ist keine Zahl. &quot;;
                        cin.clear();
                        cin.ignore(numeric_limits&lt;streamsize&gt;::max(),'\n');
                }
                z = x - y;
                cout &lt;&lt; &quot;Ergebnis: &quot; &lt;&lt; endl;
                break;

                default:
                cout &lt;&lt; &quot;Falsche Eingabe&quot;;
                break;
        }
        cout &lt;&lt; &quot;\nWenn Sie weiterrechnen wollen tippen Sie auf E: &quot;;
        cin &gt;&gt; ende;
        getchar();
}
while (ende == 'e'); {
        cout &lt;&lt; &quot;Das Programm wird beendet&quot; &lt;&lt; endl;
        }
return 0;
}
</code></pre>
<p><strong>Fragen:</strong><br />
**1.**Ich verstehe leider diese while Schleife nicht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> Kann sie mir jemand erklären?</p>
<pre><code class="language-cpp">while ((cout &lt;&lt; &quot;Erste Zahl: &quot;) &amp;&amp; !(cin &gt;&gt; x)) {
                        cout &lt;&lt; &quot;Das ist keine Zahl. &quot;;
                        cin.clear();
                        cin.ignore(numeric_limits&lt;streamsize&gt;::max(), '\n');
                }
</code></pre>
<p>Wieso wird hier <strong>!(cin &gt;&gt; x)</strong> verwendet?</p>
<p><strong>2.</strong></p>
<pre><code class="language-cpp">cin.ignore(numeric_limits&lt;streamsize&gt;::max(), '\n');
</code></pre>
<p>Was wird hier eigentlich gemacht? Wenn ich den Code bei <strong>C++ Builder 6</strong> eingebe bekomme ich jedesmal eine Fehlermeldung.</p>
<blockquote>
<p>Code-Parameter kann nicht aufgerufen werden, da der Quelltext Fehler enthält</p>
</blockquote>
<p><strong>3.</strong> Wie ihr sieht enthält mein Programm sehr viele while Schleifen? Könnte ich diese irgendwie verringern? Besser gefragt, das Programm irgendwie anders programmieren?</p>
<p><strong>4.</strong> Wie findet ihr meinen Programmierstil als <strong>Anfänger</strong>.</p>
<p>Vielen Dank im Voraus.</p>
<p>MfG<br />
<strong>T</strong>echnology</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1043517</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1043517</guid><dc:creator><![CDATA[technology]]></dc:creator><pubDate>Sun, 23 Apr 2006 17:56:08 GMT</pubDate></item><item><title><![CDATA[Reply to Nur INT zulassen on Sun, 23 Apr 2006 18:20:57 GMT]]></title><description><![CDATA[<p>technology schrieb:</p>
<blockquote>
<p>**1.**Ich verstehe leider diese while Schleife nicht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> Kann sie mir jemand erklären?</p>
</blockquote>
<pre><code class="language-cpp">while ((cout &lt;&lt; &quot;Erste Zahl: &quot;) &amp;&amp; !(cin &gt;&gt; x)) {
</code></pre>
<p>(cout &lt;&lt; &quot;Erste Zahl: &quot;) ist immer true. !(cin &gt;&gt; x) ist solange true, wie du keine Ganzzahlen eingibst.</p>
<pre><code class="language-cpp">cin.clear();
                        cin.ignore(numeric_limits&lt;streamsize&gt;::max(), '\n');
                }
</code></pre>
<p>Leert dir deinen Buffer.</p>
<p>Angenommen, das Ausgabefenster sieht folgendermaßen aus:</p>
<pre><code>Erste Zahl: 23 blubbs
</code></pre>
<p>Ich habe zwei &quot;Wörter&quot; eingegeben, die 23 wird in x gespeichert, das &quot;blubbs&quot; bleibt allerdings noch im Buffer, d. h. das nächstfolgende cin liest dieses &quot;blubbs&quot; ein, egal, was du eingibst. Das ist sicherlich nicht im Sinne des Erfinders, deshalb wird der Buffer geleert.</p>
<blockquote>
<p>Wieso wird hier <strong>!(cin &gt;&gt; x)</strong> verwendet?</p>
</blockquote>
<p>cin liefert einen Fehlerstatus, wenn in x nix Ordentliches eingelesen wurde.</p>
<blockquote>
<p><strong>2.</strong></p>
<pre><code class="language-cpp">cin.ignore(numeric_limits&lt;streamsize&gt;::max(), '\n');
</code></pre>
<p>[...] Wenn ich den Code bei <strong>C++ Builder 6</strong> eingebe bekomme ich jedesmal eine Fehlermeldung.</p>
</blockquote>
<p>Uff, wie mans beim Builder 6 machen muss, weiß ich auch nicht.</p>
<blockquote>
<p><strong>3.</strong> Wie ihr sieht enthält mein Programm sehr viele while Schleifen? Könnte ich diese irgendwie verringern? Besser gefragt, das Programm irgendwie anders programmieren?</p>
</blockquote>
<p>Natürlich. Geh zuerst mal davon aus, dass der User nur richtige Eingaben macht, und bau die Fehlerüberprüfung erst nachträglich ein. Dadurch erhälst du Code, den du auch noch selbst verstehst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1043559</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1043559</guid><dc:creator><![CDATA[Michael E.]]></dc:creator><pubDate>Sun, 23 Apr 2006 18:20:57 GMT</pubDate></item><item><title><![CDATA[Reply to Nur INT zulassen on Mon, 24 Apr 2006 06:18:54 GMT]]></title><description><![CDATA[<p>Du kannst auch die Tatsache ausnutzen, daß alle while()-Schleifen gleich aufgebaut sind und das in eine Funktion einpacken:</p>
<pre><code class="language-cpp">int lese_zahl(const string&amp; Eingabe)
{
  int val;
  while ((cout &lt;&lt; Eingabe) &amp;&amp; !(cin &gt;&gt; val)) {
    cout &lt;&lt; &quot;Das ist keine Zahl! &quot;;
    cin.clear();
    cin.ignore(numeric_limits&lt;streamsize&gt;::max(), '\n');
  }
  return val;
}

...
switch(funktion)
{
case '+':
  x=lese_zahl(&quot;Erster Summand: &quot;);
  y=lese_zahl(&quot;Zweiter Summand: &quot;);
  z=x+y;
  cout&lt;&lt;&quot;Summe: &quot;&lt;&lt;z&lt;&lt;endl;
...
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1043728</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1043728</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 24 Apr 2006 06:18:54 GMT</pubDate></item><item><title><![CDATA[Reply to Nur INT zulassen on Mon, 24 Apr 2006 06:28:29 GMT]]></title><description><![CDATA[<p>CStoll schrieb:</p>
<blockquote>
<pre><code class="language-cpp">int lese_zahl[...]
</code></pre>
</blockquote>
<p>nein! es heißt &quot;lies&quot; <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/26a0.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--warning"
      title=":warning:"
      alt="⚠"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1043731</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1043731</guid><dc:creator><![CDATA[987c36e4-e19f-473a-9948-c]]></dc:creator><pubDate>Mon, 24 Apr 2006 06:28:29 GMT</pubDate></item><item><title><![CDATA[Reply to Nur INT zulassen on Mon, 24 Apr 2006 06:49:27 GMT]]></title><description><![CDATA[<p>Ist doch egal - ich &quot;lese&quot; halt eine &quot;zahl&quot; <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/1043739</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1043739</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 24 Apr 2006 06:49:27 GMT</pubDate></item><item><title><![CDATA[Reply to Nur INT zulassen on Mon, 24 Apr 2006 08:58:49 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Zu 2.<br />
Auch beim BCB6 kommen da keine Fehlermeldungen, wenn man</p>
<pre><code class="language-cpp">#include &lt;limits&gt;
</code></pre>
<p>mit einbindet.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1043788</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1043788</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Mon, 24 Apr 2006 08:58:49 GMT</pubDate></item><item><title><![CDATA[Reply to Nur INT zulassen on Mon, 24 Apr 2006 20:48:04 GMT]]></title><description><![CDATA[<p>1. Vielen vielen dank für eure Hilfen.<br />
2. Habe jetzt dank euch gelernt wie man nur für INT die Eingabe zulassen kann.<br />
Wie könnte ich so etwas mit den Strings realisieren?<br />
Genauso?</p>
<p>MfG<br />
<strong>T</strong>echnology</p>
<p><strong>EDIT: Wenn ich meinem Freund das Programm schicke z.b. unter dem Namen &quot;f.exe&quot; bekommt er so eine Meldung.<br />
<a href="http://img249.imageshack.us/img249/224/fehler8xu.jpg" rel="nofollow">http://img249.imageshack.us/img249/224/fehler8xu.jpg</a></strong></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1044491</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1044491</guid><dc:creator><![CDATA[technology]]></dc:creator><pubDate>Mon, 24 Apr 2006 20:48:04 GMT</pubDate></item><item><title><![CDATA[Reply to Nur INT zulassen on Mon, 24 Apr 2006 20:46:04 GMT]]></title><description><![CDATA[<p>probieren geht über studieren</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1044493</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1044493</guid><dc:creator><![CDATA[joomoo]]></dc:creator><pubDate>Mon, 24 Apr 2006 20:46:04 GMT</pubDate></item><item><title><![CDATA[Reply to Nur INT zulassen on Tue, 25 Apr 2006 09:05:26 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/10052">@technology</a><br />
Schau dir mal das hier<br />
<a href="http://www.c-plusplus.net/forum/viewtopic.php?t=39164" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic.php?t=39164</a> aus der C++Builder FAQ an. Das könnte helfen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1044653</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1044653</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Tue, 25 Apr 2006 09:05:26 GMT</pubDate></item></channel></rss>