<?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.getline()]]></title><description><![CDATA[<p>Wenn ich bei folgendem Beispiel:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
using namespace std;

const int SIZE=20;

int main()
{
    char a[SIZE];
    char b[SIZE];
    cin.getline(a,SIZE);
    a[SIZE-1]='\0';
    cout &lt;&lt; a &lt;&lt; endl;
    cin.getline(b,SIZE);
    b[SIZE-1]='\0';
    cout &lt;&lt; b &lt;&lt; endl;

    return 0;
}
</code></pre>
<p>Beim ersten &quot;cin.getline(a,SIZE)&quot; &quot;WorteWorteWorteWorteWorte&quot; (25 Zeichen) eingebe, dann müsste doch eigentlich &quot;cin.getline(b.SIZE)&quot; nicht mehr aufgerufen werden und die Ausgabe wäre dann:</p>
<blockquote>
<p>WorteWorteWorteWorteWorte //meine Eingabe + ENTER<br />
WorteWorteWorteWort // &quot;e&quot; wird abgeschnitten, wegen a[SIZE-1]='\0';<br />
Worte // cout &lt;&lt; b &lt;&lt; endl; Das was noch im Pufer drin stand</p>
</blockquote>
<p>Aber komischerweise wird das letzte &quot;Worte&quot; nicht hingeschriben bei mir, da steht nur:</p>
<blockquote>
<p>WorteWorteWorteWorteWorte //meine Eingabe + ENTER<br />
WorteWorteWorteWort</p>
</blockquote>
<p>Doch nach meiner Logik müsste das doch zum Schluss nochmal das &quot;Worte&quot; kommen oder?<br />
MfG<br />
Stromberg</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/199496/cin-getline</link><generator>RSS for Node</generator><lastBuildDate>Sat, 03 Oct 2026 16:26:23 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/199496.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 03 Dec 2007 18:56:52 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to cin.getline() on Mon, 03 Dec 2007 18:56:52 GMT]]></title><description><![CDATA[<p>Wenn ich bei folgendem Beispiel:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
using namespace std;

const int SIZE=20;

int main()
{
    char a[SIZE];
    char b[SIZE];
    cin.getline(a,SIZE);
    a[SIZE-1]='\0';
    cout &lt;&lt; a &lt;&lt; endl;
    cin.getline(b,SIZE);
    b[SIZE-1]='\0';
    cout &lt;&lt; b &lt;&lt; endl;

    return 0;
}
</code></pre>
<p>Beim ersten &quot;cin.getline(a,SIZE)&quot; &quot;WorteWorteWorteWorteWorte&quot; (25 Zeichen) eingebe, dann müsste doch eigentlich &quot;cin.getline(b.SIZE)&quot; nicht mehr aufgerufen werden und die Ausgabe wäre dann:</p>
<blockquote>
<p>WorteWorteWorteWorteWorte //meine Eingabe + ENTER<br />
WorteWorteWorteWort // &quot;e&quot; wird abgeschnitten, wegen a[SIZE-1]='\0';<br />
Worte // cout &lt;&lt; b &lt;&lt; endl; Das was noch im Pufer drin stand</p>
</blockquote>
<p>Aber komischerweise wird das letzte &quot;Worte&quot; nicht hingeschriben bei mir, da steht nur:</p>
<blockquote>
<p>WorteWorteWorteWorteWorte //meine Eingabe + ENTER<br />
WorteWorteWorteWort</p>
</blockquote>
<p>Doch nach meiner Logik müsste das doch zum Schluss nochmal das &quot;Worte&quot; kommen oder?<br />
MfG<br />
Stromberg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1414408</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1414408</guid><dc:creator><![CDATA[Stromberg]]></dc:creator><pubDate>Mon, 03 Dec 2007 18:56:52 GMT</pubDate></item><item><title><![CDATA[Reply to cin.getline() on Tue, 04 Dec 2007 01:02:50 GMT]]></title><description><![CDATA[<p>Sieht so aus als würde getline nicht nach deiner Logik arbeiten. Und deine Frage war jetzt ob getline nach deiner Logik so arbeitet wie beschrieben? Komische Frage, die Antwort hast du selbst gepostet...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1414533</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1414533</guid><dc:creator><![CDATA[blablub]]></dc:creator><pubDate>Tue, 04 Dec 2007 01:02:50 GMT</pubDate></item><item><title><![CDATA[Reply to cin.getline() on Tue, 04 Dec 2007 11:02:51 GMT]]></title><description><![CDATA[<p>Benutze lieber std::string und std::getline(std::istream &amp;, std::string &amp;, char delim='\n').</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1414706</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1414706</guid><dc:creator><![CDATA[Th]]></dc:creator><pubDate>Tue, 04 Dec 2007 11:02:51 GMT</pubDate></item><item><title><![CDATA[Reply to cin.getline() on Tue, 04 Dec 2007 11:57:01 GMT]]></title><description><![CDATA[<p>Ich glaub ich hab das was ich mein irgendwie falsch formuliert. Hab gemeint, das wenn man die max. Zeichenanzahl von cin.getline überschreitet, das dann ja noch n paar Zeichen im cin Puffer stehen müssen. Nur werden diese merkwürdigerweiße beim nächsten cin.getline nicht mehr ausgegeben.<br />
aber am besten verwende ich getline für std::string.<br />
MfG<br />
Stromberg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1414735</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1414735</guid><dc:creator><![CDATA[Stromberg]]></dc:creator><pubDate>Tue, 04 Dec 2007 11:57:01 GMT</pubDate></item></channel></rss>