<?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[&amp;quot;getline&amp;quot; Kommando wird ignoriert]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich bin gerade dabei c++ zu erlernen und habe soeben mein erstes, gröberes Problem das ich nicht alleine Lösen kann.<br />
Also wie der Threadname schon sagt wird ein &quot;getline&quot; Kommando vom Computer beim Kompilieren überlesen und macht einfach weiter als würde dieses Kommando nicht dort stehen. Ich hoffe ihr versteht was ich meine...</p>
<p>So sieht der Code aus:</p>
<pre><code>int b, i;
	cout &lt;&lt; &quot;Bitte geben sie ihr Alter an\n&quot;;
	cin &gt;&gt; i;
	b = 100 - i;
	cout &lt;&lt; &quot;Soso, sie haben &quot; &lt;&lt; i &lt;&lt; &quot; angegeben! Ich hoffe das stimmt :)\n&quot;;
	cout &lt;&lt; &quot;Wow, das heißt sie werden in einem Jahr &quot; &lt;&lt; ++i &lt;&lt; &quot;!\n&quot;;
	cout &lt;&lt; &quot;Und in &quot; &lt;&lt; b &lt;&lt; &quot; Jahren werden sie dann 100! Unglaublich!\n&quot;;

// cin (input) mit Strings - auch sehr wichtig

	int m, d;
	string name, datum;
	cout &lt;&lt; &quot;Wie heißt du eigentlich? \n&quot;;
	getline (cin, name);        &lt;-- DAS WIRD ÜBERSPRUNGEN
	cout &lt;&lt; &quot;Hallo &quot; &lt;&lt; name &lt;&lt; &quot;! Wann genau bist du denn geboren (dd/mm/yyyy)? &quot;;
	getline (cin, datum);       &lt;-- HIER WIRD WEITERGEMACHT
        .
        .
        .
</code></pre>
<p>Ausgabe ist:</p>
<p>Bitte geben sie ihr Alter an<br />
[EINGABE]16<br />
Soso, sie haben 16 angegeben! Ich hoffe das stimmt <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="🙂"
    /><br />
Wow, das heißt sie werden in einem Jahr 17!<br />
Und in 84 Jahren werden sie dann 100! Unglaublich!<br />
Wie heißt du eigentlich?<br />
[Diese Eingabe wird übersprungen]<br />
Hallo ! Wann genau bist du denn geboren (dd/mm/yyyy)?<br />
[EINGABE]</p>
<p>Irgendwo anders hab' ich gelesen, dass das getline wegen dem &quot;\n&quot; davor übersprungen wird, nur Lösung gab es keine dazu.<br />
Also hoffe ich, dass ihr mir helfen könnt.</p>
<p>lg.<br />
Groebi</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/203888/quot-getline-quot-kommando-wird-ignoriert</link><generator>RSS for Node</generator><lastBuildDate>Thu, 08 Oct 2026 03:58:29 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/203888.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 27 Jan 2008 20:22:47 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to &amp;quot;getline&amp;quot; Kommando wird ignoriert on Sun, 27 Jan 2008 20:22:47 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich bin gerade dabei c++ zu erlernen und habe soeben mein erstes, gröberes Problem das ich nicht alleine Lösen kann.<br />
Also wie der Threadname schon sagt wird ein &quot;getline&quot; Kommando vom Computer beim Kompilieren überlesen und macht einfach weiter als würde dieses Kommando nicht dort stehen. Ich hoffe ihr versteht was ich meine...</p>
<p>So sieht der Code aus:</p>
<pre><code>int b, i;
	cout &lt;&lt; &quot;Bitte geben sie ihr Alter an\n&quot;;
	cin &gt;&gt; i;
	b = 100 - i;
	cout &lt;&lt; &quot;Soso, sie haben &quot; &lt;&lt; i &lt;&lt; &quot; angegeben! Ich hoffe das stimmt :)\n&quot;;
	cout &lt;&lt; &quot;Wow, das heißt sie werden in einem Jahr &quot; &lt;&lt; ++i &lt;&lt; &quot;!\n&quot;;
	cout &lt;&lt; &quot;Und in &quot; &lt;&lt; b &lt;&lt; &quot; Jahren werden sie dann 100! Unglaublich!\n&quot;;

// cin (input) mit Strings - auch sehr wichtig

	int m, d;
	string name, datum;
	cout &lt;&lt; &quot;Wie heißt du eigentlich? \n&quot;;
	getline (cin, name);        &lt;-- DAS WIRD ÜBERSPRUNGEN
	cout &lt;&lt; &quot;Hallo &quot; &lt;&lt; name &lt;&lt; &quot;! Wann genau bist du denn geboren (dd/mm/yyyy)? &quot;;
	getline (cin, datum);       &lt;-- HIER WIRD WEITERGEMACHT
        .
        .
        .
</code></pre>
<p>Ausgabe ist:</p>
<p>Bitte geben sie ihr Alter an<br />
[EINGABE]16<br />
Soso, sie haben 16 angegeben! Ich hoffe das stimmt <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="🙂"
    /><br />
Wow, das heißt sie werden in einem Jahr 17!<br />
Und in 84 Jahren werden sie dann 100! Unglaublich!<br />
Wie heißt du eigentlich?<br />
[Diese Eingabe wird übersprungen]<br />
Hallo ! Wann genau bist du denn geboren (dd/mm/yyyy)?<br />
[EINGABE]</p>
<p>Irgendwo anders hab' ich gelesen, dass das getline wegen dem &quot;\n&quot; davor übersprungen wird, nur Lösung gab es keine dazu.<br />
Also hoffe ich, dass ihr mir helfen könnt.</p>
<p>lg.<br />
Groebi</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1444725</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1444725</guid><dc:creator><![CDATA[Groebi]]></dc:creator><pubDate>Sun, 27 Jan 2008 20:22:47 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;getline&amp;quot; Kommando wird ignoriert on Sun, 27 Jan 2008 20:47:12 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">std::istream&amp; clear_stream(std::istream&amp; in)
{ return in.clear(), in.ignore(std::numeric_limits&lt;std::streamsize&gt;::max(), '\n'); }
</code></pre>
<p>dann clear_stream(std::cin) vorm Einlesen aufrufen und fertig!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1444733</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1444733</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Sun, 27 Jan 2008 20:47:12 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;getline&amp;quot; Kommando wird ignoriert on Sun, 27 Jan 2008 21:24:44 GMT]]></title><description><![CDATA[<p>(D)Evil schrieb:</p>
<blockquote>
<pre><code class="language-cpp">std::istream&amp; clear_stream(std::istream&amp; in)
{ return in.clear(), in.ignore(std::numeric_limits&lt;std::streamsize&gt;::max(), '\n'); }
</code></pre>
<p>dann clear_stream(std::cin) vorm Einlesen aufrufen und fertig!</p>
</blockquote>
<p>muss dass so schwierig sein??</p>
<p>un wieso nich so:</p>
<pre><code class="language-cpp">#include&lt;iostream&gt;
using namespace std;

int main()
{
int b, i;
    cout &lt;&lt; &quot;Bitte geben sie ihr Alter an\n&quot;;
    cin &gt;&gt; i;
    b = 100 - i;
    cout &lt;&lt; &quot;Soso, sie haben &quot; &lt;&lt; i &lt;&lt; &quot; angegeben! Ich hoffe das stimmt :)\n&quot;;
    cout &lt;&lt; &quot;Wow, das heißt sie werden in einem Jahr &quot; &lt;&lt; ++i &lt;&lt; &quot;!\n&quot;;
    cout &lt;&lt; &quot;Und in &quot; &lt;&lt; b &lt;&lt; &quot; Jahren werden sie dann 100! Unglaublich!\n&quot;;

// cin (input) mit Strings - auch sehr wichtig

    int m, d;
    string name, datum;
    cout &lt;&lt; &quot;Wie heißt du eigentlich? \n&quot;;
    cin.ignore();              //  1 Befehl!
    getline (cin, name);       // &lt;-- DAS WIRD Nicht mehr ÜBERSPRUNGEN
    cout &lt;&lt; &quot;Hallo &quot; &lt;&lt; name &lt;&lt; &quot;! Wann genau bist du denn geboren (dd/mm/yyyy)? &quot;;
    getline (cin, datum);      
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1444746</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1444746</guid><dc:creator><![CDATA[hmm...]]></dc:creator><pubDate>Sun, 27 Jan 2008 21:24:44 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;getline&amp;quot; Kommando wird ignoriert on Sun, 27 Jan 2008 21:40:14 GMT]]></title><description><![CDATA[<p>danke für deine Antwort (D)Evil!</p>
<p>Doch wie gesagt, ich bin Anfänger und kann sehr wenig, ja eigentlich noch nichts mit dieser Lösung anfangen, tut mir leid.</p>
<p>Ah! Gerade ist noch eine Mögliche Lösung angekommen.<br />
Witzig, genau das hab ich mir auch schon überlegt, und es hat ja auch funktioniert, doch ich würde gerne die Ursache dieses Problems kennen lernen und darum harke ich nochmal nach <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>
<p>Also wenn mir das Jemand erlären könnte, dann wäre ich sehr dankbar.<br />
Trotzdem, danke euch Beiden!</p>
<p>lg.<br />
groebi</p>
<p>PS: (D)Evil - Morgen bist du 3 Jahre hier angemeldet. Alles Gute <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/1444752</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1444752</guid><dc:creator><![CDATA[Groebi]]></dc:creator><pubDate>Sun, 27 Jan 2008 21:40:14 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;getline&amp;quot; Kommando wird ignoriert on Sun, 27 Jan 2008 22:16:08 GMT]]></title><description><![CDATA[<p>Jo danke <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>Ehm es lieggt daran das die eingabe gepuffert ist und noch reste im puffer sind <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>
]]></description><link>https://www.c-plusplus.net/forum/post/1444761</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1444761</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Sun, 27 Jan 2008 22:16:08 GMT</pubDate></item></channel></rss>