<?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[Kleine Funktion zum Umgehen von Fehler bei Eingabe von char, wenn int erwartet wird.]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe eine Funktion programmiert (<a href="http://webentwicklung.virtual-meetings.de/2008/06/21/c-exceptions-bei-eingabe-von-char-wenn-int-erwartet-wird/" rel="nofollow">http://webentwicklung.virtual-meetings.de/2008/06/21/c-exceptions-bei-eingabe-von-char-wenn-int-erwartet-wird/</a>), die es verhindert, dass mein Konsolenprogramm bei einer Eingabe von einem Buchstaben in eine Int-Variable abstürtzt.</p>
<p>Ist das so sauber gelöst? (ich bin blutiger Anfänger und habe bisher nur PHP-Kentnisse)</p>
<p>Ich freue mich auf Feedback!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/216326/kleine-funktion-zum-umgehen-von-fehler-bei-eingabe-von-char-wenn-int-erwartet-wird</link><generator>RSS for Node</generator><lastBuildDate>Sun, 11 Oct 2026 15:45:20 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/216326.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 22 Jun 2008 19:14:49 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Kleine Funktion zum Umgehen von Fehler bei Eingabe von char, wenn int erwartet wird. on Sun, 22 Jun 2008 19:14:49 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe eine Funktion programmiert (<a href="http://webentwicklung.virtual-meetings.de/2008/06/21/c-exceptions-bei-eingabe-von-char-wenn-int-erwartet-wird/" rel="nofollow">http://webentwicklung.virtual-meetings.de/2008/06/21/c-exceptions-bei-eingabe-von-char-wenn-int-erwartet-wird/</a>), die es verhindert, dass mein Konsolenprogramm bei einer Eingabe von einem Buchstaben in eine Int-Variable abstürtzt.</p>
<p>Ist das so sauber gelöst? (ich bin blutiger Anfänger und habe bisher nur PHP-Kentnisse)</p>
<p>Ich freue mich auf Feedback!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1533828</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1533828</guid><dc:creator><![CDATA[fat32]]></dc:creator><pubDate>Sun, 22 Jun 2008 19:14:49 GMT</pubDate></item><item><title><![CDATA[Reply to Kleine Funktion zum Umgehen von Fehler bei Eingabe von char, wenn int erwartet wird. on Sun, 22 Jun 2008 19:16:17 GMT]]></title><description><![CDATA[<p>Oh, bin in diesem Forum überhaupt richtig mit Konsolenprogrammen?<br />
Wenn nein, bitte verschieben!</p>
<p>Sorry</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1533830</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1533830</guid><dc:creator><![CDATA[fat32]]></dc:creator><pubDate>Sun, 22 Jun 2008 19:16:17 GMT</pubDate></item><item><title><![CDATA[Reply to Kleine Funktion zum Umgehen von Fehler bei Eingabe von char, wenn int erwartet wird. on Sun, 22 Jun 2008 20:36:47 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-14774.html" rel="nofollow">akari</a> aus dem Forum <a href="http://www.c-plusplus.net/forum/viewforum-var-f-is-2.html" rel="nofollow">VCL (C++ Builder)</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/1533863</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1533863</guid><dc:creator><![CDATA[C++ Forumbot]]></dc:creator><pubDate>Sun, 22 Jun 2008 20:36:47 GMT</pubDate></item><item><title><![CDATA[Reply to Kleine Funktion zum Umgehen von Fehler bei Eingabe von char, wenn int erwartet wird. on Sun, 22 Jun 2008 21:15:21 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">return (int)speicher-'0';
</code></pre>
<p>das int hier ist nicht erforderlich</p>
<p>char ist ja auch nichts anderes, als nen int</p>
<p>aber getch etc ist halt kein C/C++ ^^<br />
eigtl gibts für so was ausreichend fkt...</p>
<pre><code class="language-cpp">template &lt;typename T&gt;
	T eingabe (void)
		{
			T R;
			while (!(std::cin &gt;&gt; R))
				{
					std::string muell;
					std::cin.clear ();
					std::getline (std::cin, muell);
					std::cout &lt;&lt; &quot;Eingabe bitte korrigieren&quot; &lt;&lt; std::endl;
				}
			return R;
		}
</code></pre>
<p>sollte auch gehen glaube ich - aber vll kann man das mit dem stream leeren noch bissl eleganter machen ^^</p>
<p>bb</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1533875</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1533875</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Sun, 22 Jun 2008 21:15:21 GMT</pubDate></item></channel></rss>