<?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[cin-Eingabefehler abfangen und behandeln]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>ich möchte ein Programm schreiben, mit dem ich double-Werte in einen Vector einspeisen kann.<br />
An einer Stelle komme ich nicht weiter: Die Eingabe soll mit dem Eingeben eines bestimmten Buchstabens beendet werden. Wie lässt sich das realisieren, wenn ich zuvor nur double-Werte entgegennehme?</p>
<p>Beste Grüße und vielen Dank vorab.<br />
Martin</p>
<p>Mein bisheriger Code:</p>
<pre><code>int main() {

    vector&lt;double&gt;vValue;
    double tempValue;
    bool loopVar = true;

    cout &lt;&lt; &quot;Geben Sie einige Zahlen ein (mit 'q' beenden Sie die Eingabe):&quot;;
    try {
        while (loopVar == true) {
            if (!(cin &gt;&gt; tempValue)) {
                throw 1;
            };
            if (tempValue == 'q') {
                loopVar = false;
            }
            vValue.push_back(tempValue);
        }
    }
    catch(int x){

    }

    return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/320733/cin-eingabefehler-abfangen-und-behandeln</link><generator>RSS for Node</generator><lastBuildDate>Thu, 23 Jul 2026 18:38:08 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/320733.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 09 Oct 2013 17:29:21 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to cin-Eingabefehler abfangen und behandeln on Wed, 09 Oct 2013 17:29:21 GMT]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>ich möchte ein Programm schreiben, mit dem ich double-Werte in einen Vector einspeisen kann.<br />
An einer Stelle komme ich nicht weiter: Die Eingabe soll mit dem Eingeben eines bestimmten Buchstabens beendet werden. Wie lässt sich das realisieren, wenn ich zuvor nur double-Werte entgegennehme?</p>
<p>Beste Grüße und vielen Dank vorab.<br />
Martin</p>
<p>Mein bisheriger Code:</p>
<pre><code>int main() {

    vector&lt;double&gt;vValue;
    double tempValue;
    bool loopVar = true;

    cout &lt;&lt; &quot;Geben Sie einige Zahlen ein (mit 'q' beenden Sie die Eingabe):&quot;;
    try {
        while (loopVar == true) {
            if (!(cin &gt;&gt; tempValue)) {
                throw 1;
            };
            if (tempValue == 'q') {
                loopVar = false;
            }
            vValue.push_back(tempValue);
        }
    }
    catch(int x){

    }

    return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2359223</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2359223</guid><dc:creator><![CDATA[martini3k1]]></dc:creator><pubDate>Wed, 09 Oct 2013 17:29:21 GMT</pubDate></item><item><title><![CDATA[Reply to cin-Eingabefehler abfangen und behandeln on Wed, 09 Oct 2013 17:52:44 GMT]]></title><description><![CDATA[<p>Schau mal hier:</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;vector&gt;
using namespace std;

int main()
{
	vector&lt;double&gt; vec;

	for(;;)
	{
		double d;
		if( cin&gt;&gt;d )
		{
			vec.push_back( d );
		}
		else
		{
			cin.clear();
			char c;
			cin &gt;&gt; c;
			if( c=='q' )
				break;
			cin.ignore(999,'\n');
		}
	}
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2359228</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2359228</guid><dc:creator><![CDATA[out]]></dc:creator><pubDate>Wed, 09 Oct 2013 17:52:44 GMT</pubDate></item><item><title><![CDATA[Reply to cin-Eingabefehler abfangen und behandeln on Wed, 09 Oct 2013 18:05:54 GMT]]></title><description><![CDATA[<p>Sau gut, vielen Dank! Manchmal ist es so einfach und trotzdem wäre ich da nicht so schnell drauf gekommen :p</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2359237</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2359237</guid><dc:creator><![CDATA[martini3k1]]></dc:creator><pubDate>Wed, 09 Oct 2013 18:05:54 GMT</pubDate></item></channel></rss>