<?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[std::cin Eingabepuffer leeren]]></title><description><![CDATA[<p>Hey!</p>
<p>Ich bekomm das einfach nicht hin! Habe von ignore(), clear() über sync() bis hin zu rdbuf()-&gt;blabla alles ausprobiert.</p>
<p>Wie lösche ich den Eingabepuffer von std::cin?</p>
<p>Ich frage eine Eingabe nach einer bestimmten Länge ab, stimmt diese nicht, wird eine Nachricht ausgegeben, 4 Sekunden per Sleep() gewartet und wenn man währenddessen etwas eingibt, wird das dann beim nächsten std::cin angezeigt. Das will ich aber nicht.</p>
<p>MfG</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/192582/std-cin-eingabepuffer-leeren</link><generator>RSS for Node</generator><lastBuildDate>Thu, 20 Aug 2026 17:25:03 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/192582.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 16 Sep 2007 14:42:57 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to std::cin Eingabepuffer leeren on Sun, 16 Sep 2007 14:42:57 GMT]]></title><description><![CDATA[<p>Hey!</p>
<p>Ich bekomm das einfach nicht hin! Habe von ignore(), clear() über sync() bis hin zu rdbuf()-&gt;blabla alles ausprobiert.</p>
<p>Wie lösche ich den Eingabepuffer von std::cin?</p>
<p>Ich frage eine Eingabe nach einer bestimmten Länge ab, stimmt diese nicht, wird eine Nachricht ausgegeben, 4 Sekunden per Sleep() gewartet und wenn man währenddessen etwas eingibt, wird das dann beim nächsten std::cin angezeigt. Das will ich aber nicht.</p>
<p>MfG</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1366383</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1366383</guid><dc:creator><![CDATA[ceplusplus@loggedoff]]></dc:creator><pubDate>Sun, 16 Sep 2007 14:42:57 GMT</pubDate></item><item><title><![CDATA[Reply to std::cin Eingabepuffer leeren on Sun, 16 Sep 2007 16:20:37 GMT]]></title><description><![CDATA[<p>tjo ... ehm warte lass überlegen ... wir könnten nen failbit gesetzt haben? evt. ok ... also brauchen wir clear. Hmm dann soll der uns mal alles rauswerfen was wir nichtmehr brauchen!</p>
<pre><code class="language-cpp">std::cin.sync();
std::cin.clear();
std::cin.ignore(std::numeric_limits&lt;std::streamsize&gt;::max(), '\n');
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1366454</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1366454</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Sun, 16 Sep 2007 16:20:37 GMT</pubDate></item><item><title><![CDATA[Reply to std::cin Eingabepuffer leeren on Sun, 16 Sep 2007 16:50:36 GMT]]></title><description><![CDATA[<pre><code>1&gt;c:\data\c++\tests\minigame\minigame\core.cpp(37) : warning C4003: not enough actual parameters for macro 'max'
1&gt;c:\data\c++\tests\minigame\minigame\core.cpp(37) : error C2589: '(' : illegal token on right side of '::'
1&gt;c:\data\c++\tests\minigame\minigame\core.cpp(37) : error C2143: syntax error : missing ')' before '::'
1&gt;c:\data\c++\tests\minigame\minigame\core.cpp(37) : error C2059: syntax error : ')'
</code></pre>
<p>Und mit</p>
<pre><code class="language-cpp">std::cin.sync(); 
std::cin.clear(); 
std::cin.ignore(std::numeric_limits&lt;std::streamsize&gt;::max, '\n');
</code></pre>
<p>haben wir</p>
<pre><code>cannot convert parameter 1 from 'std::numeric_limits&lt;int&gt;::_Ty (__cdecl *)(void) throw()' to 'std::streamsize'
</code></pre>
<p>MfG</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1366473</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1366473</guid><dc:creator><![CDATA[ceplusplus@loggedoff]]></dc:creator><pubDate>Sun, 16 Sep 2007 16:50:36 GMT</pubDate></item><item><title><![CDATA[Reply to std::cin Eingabepuffer leeren on Sun, 16 Sep 2007 16:58:04 GMT]]></title><description><![CDATA[<p>ceplusplus@loggedoff schrieb:</p>
<blockquote>
<pre><code>1&gt;c:\data\c++\tests\minigame\minigame\core.cpp(37) : warning C4003: not enough actual parameters for [b]macro 'max'[/b]
</code></pre>
</blockquote>
<p>falls du &lt;windows.h&gt; inkludierst, definiere vorher das Makro NO_MINMAX.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1366474</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1366474</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Sun, 16 Sep 2007 16:58:04 GMT</pubDate></item><item><title><![CDATA[Reply to std::cin Eingabepuffer leeren on Sun, 16 Sep 2007 18:38:50 GMT]]></title><description><![CDATA[<p>Hat nix gebracht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1366548</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1366548</guid><dc:creator><![CDATA[ceplusplus@loggedoff]]></dc:creator><pubDate>Sun, 16 Sep 2007 18:38:50 GMT</pubDate></item><item><title><![CDATA[Reply to std::cin Eingabepuffer leeren on Sun, 16 Sep 2007 18:52:21 GMT]]></title><description><![CDATA[<p>ceplusplus@loggedoff schrieb:</p>
<blockquote>
<p>Hat nix gebracht.</p>
</blockquote>
<p>Dann finde den Übeltäter der das Makro max definiert, das macht den Ausdruck im Zusammenhang mit numeric_limits kaputt. Wenn's nicht windows.h ist können wir nicht wissen welcher das sein könnte.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1366562</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1366562</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Sun, 16 Sep 2007 18:52:21 GMT</pubDate></item><item><title><![CDATA[Reply to std::cin Eingabepuffer leeren on Sun, 16 Sep 2007 18:53:56 GMT]]></title><description><![CDATA[<p>camper schrieb:</p>
<blockquote>
<p>ceplusplus@loggedoff schrieb:</p>
<blockquote>
<pre><code>1&gt;c:\data\c++\tests\minigame\minigame\core.cpp(37) : warning C4003: not enough actual parameters for [b]macro 'max'[/b]
</code></pre>
</blockquote>
<p>falls du &lt;windows.h&gt; inkludierst, definiere vorher das Makro NO_MINMAX.</p>
</blockquote>
<p>NOMINMAX IMHO</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1366564</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1366564</guid><dc:creator><![CDATA[LMAO]]></dc:creator><pubDate>Sun, 16 Sep 2007 18:53:56 GMT</pubDate></item><item><title><![CDATA[Reply to std::cin Eingabepuffer leeren on Sun, 16 Sep 2007 20:29:22 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">std::cin.sync();
std::cin.clear();
std::cin.ignore(std::numeric_limits&lt;std::streamsize&gt;::max(), '\n');
</code></pre>
<p>... sollte eigentlich gehen ... die Header:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt; // std::cin
#include &lt;limits&gt; // std::numeric_limits
#ifdef max
#undef max
#endif // max
</code></pre>
<p>...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1366624</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1366624</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Sun, 16 Sep 2007 20:29:22 GMT</pubDate></item><item><title><![CDATA[Reply to std::cin Eingabepuffer leeren on Mon, 17 Sep 2007 00:37:25 GMT]]></title><description><![CDATA[<p>Mit NOMINMAX wird nun kompiliert, jedoch muss ich nun 1. zwei mal Enter drücken und 2. wird der Eingabepuffer noch immer nicht geleert...</p>
<p>Hab den code sowohl vor cin als auch nach cin versucht.</p>
<p>Da habt ihr mal den ursprünglichen code:</p>
<pre><code class="language-cpp">while(player.getName().empty())
	{
		ic::con.clearText();
		ic::con.setCurPos(0, 0);

		std::cout &lt;&lt; &quot;***** :-) Welcome to Brchi's great network MiniGame (-: ****&quot; &lt;&lt; std::endl &lt;&lt; std::endl;
		std::cout &lt;&lt; &quot;What's your name, stranger?&quot; &lt;&lt; std::endl;

		std::string name;
		std::getline(std::cin, name);

		if(name.length() &lt; 3 || name.length() &gt; 20)
		{
			ic::con.clearText();
			ic::con.setCurPos(0, 0);

			redOut(&quot;Your name must have at least 3 and at most 20 characters!&quot;);
			Sleep(4000);
		}
		else
			player.setName(name);
	}
</code></pre>
<p>Was könnte ich noch versuchen? Wiegesagt, wenn ich während der Nachricht &quot;Your name must have....&quot; Zeichen tippe, erscheinen die dann beim nächsten cin...</p>
<p>MfG</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1366669</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1366669</guid><dc:creator><![CDATA[ceplusplus@loggedoff]]></dc:creator><pubDate>Mon, 17 Sep 2007 00:37:25 GMT</pubDate></item><item><title><![CDATA[Reply to std::cin Eingabepuffer leeren on Mon, 17 Sep 2007 05:01:48 GMT]]></title><description><![CDATA[<p>1. ich vermute, du fährst das visual studio .. dann hast du es nicht gepatch 't, heißt: getline hat das doppelte enter problem. (ich weiß nicht, ob die msdn den patch link noch zur verfügung stellt für das studio, such mal...)</p>
<p>(hier ein handfix, aber vorsicht...)<br />
<a href="http://people.msoe.edu/~taylor/resources/msvc60.htm" rel="nofollow">http://people.msoe.edu/~taylor/resources/msvc60.htm</a></p>
<ol start="2">
<li></li>
</ol>
<p>std::cin.clear();<br />
std::cin.ignore(std::numeric_limits<a href="std::streamsize" rel="nofollow">std::streamsize</a>::max(), '\n');</p>
<p>müssen vor die neue eingabe (hier: getline). damit 'öffnest' du erst den buffer und holst im nächsten schritt alle noch verbliebenenzeichen raus bis zum '\n' (also das eingegebene return).</p>
<p>hier mal eine diskussion darüber<br />
<a href="http://groups.google.de/group/comp.lang.c++.moderated/browse_frm/thread/21ad2d891802f40c/655af48a668ad266?hl=de&amp;lr=&amp;rnum=3&amp;prev=/groups%3Fq%3Din_avail%2Bproblem%2Bstream%2Bbuffer%26hl%3Dde%26lr%3D%26group%3Dcomp.lang.c%252B%252B.*%26selm%3Dd6652001.0408180130.7bbf5fd6%2540posting.google.com%26rnum%3D3#655af48a668ad266" rel="nofollow">http://groups.google.de/group/comp.lang.c++.moderated/browse_frm/thread/21ad2d891802f40c/655af48a668ad266?hl=de&amp;lr=&amp;rnum=3&amp;prev=/groups%3Fq%3Din_avail%2Bproblem%2Bstream%2Bbuffer%26hl%3Dde%26lr%3D%26group%3Dcomp.lang.c%2B%2B.*%26selm%3Dd6652001.0408180130.7bbf5fd6%40posting.google.com%26rnum%3D3#655af48a668ad266</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1366686</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1366686</guid><dc:creator><![CDATA[elise]]></dc:creator><pubDate>Mon, 17 Sep 2007 05:01:48 GMT</pubDate></item><item><title><![CDATA[Reply to std::cin Eingabepuffer leeren on Mon, 17 Sep 2007 05:53:19 GMT]]></title><description><![CDATA[<p>Falls du immer noch VC++ 6 fährst, ist es Zeit auf VC++ 2005 Express Edition umzusteigen - vollkommen kostenlos.</p>
<p>Falls du unbedingt VC++ 6 weiterbenutzen möchtest findet sich der Patch hier: <a href="http://fara.cs.uni-potsdam.de/~kaufmann/?page=Programming&amp;ProgKNr=1#Code" rel="nofollow">http://fara.cs.uni-potsdam.de/~kaufmann/?page=Programming&amp;ProgKNr=1#Code</a> -&gt; STLFix</p>
<p>MfG SideWinder</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1366698</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1366698</guid><dc:creator><![CDATA[SideWinder]]></dc:creator><pubDate>Mon, 17 Sep 2007 05:53:19 GMT</pubDate></item><item><title><![CDATA[Reply to std::cin Eingabepuffer leeren on Mon, 17 Sep 2007 06:31:06 GMT]]></title><description><![CDATA[<p>den patch bei hume hab ich eben wie wahnsinnig gesucht *g*</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1366707</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1366707</guid><dc:creator><![CDATA[elise]]></dc:creator><pubDate>Mon, 17 Sep 2007 06:31:06 GMT</pubDate></item><item><title><![CDATA[Reply to std::cin Eingabepuffer leeren on Mon, 17 Sep 2007 12:10:58 GMT]]></title><description><![CDATA[<p>Danke, aber ich benutze VC++ 2005 Express...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1366895</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1366895</guid><dc:creator><![CDATA[ceplusplus@loggedoff]]></dc:creator><pubDate>Mon, 17 Sep 2007 12:10:58 GMT</pubDate></item></channel></rss>