<?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[ueberspringt cin zeile]]></title><description><![CDATA[<p>hallo,<br />
hab ein problem mit cin bzw cin.getline.<br />
das ist ein einfaches eingeben/ausgeben aus txtdatei-programm:</p>
<p>die main</p>
<pre><code class="language-cpp">#include &quot;cperson.h&quot;
#include &quot;ckunde.h&quot;

void main (void)
{
CKunde k[100];
int auswahl;
int i=0;
cout &lt;&lt; &quot;Willkommen&quot; &lt;&lt; endl;
cout &lt;&lt; &quot;Was wollen Sie machen ?&quot; &lt;&lt; endl;
cout &lt;&lt; &quot;1. Kunde schreiben&quot; &lt;&lt; endl;
cout &lt;&lt; &quot;2. Kunde lesen&quot; &lt;&lt; endl;
cin &gt;&gt; auswahl;
if(auswahl == 1)
{
	k[i].daten_schreiben();
         i++;
}
}
</code></pre>
<p>die kunde.cpp</p>
<pre><code class="language-cpp">#include &quot;CKunde.h&quot;

CKunde::CKunde(void)
{

//....

void CKunde::daten_schreiben(void)
{
      cout &lt;&lt; &quot;--------------------------------------&quot; &lt;&lt; endl;
      cout &lt;&lt; &quot;Eingabe Daten&quot; &lt;&lt; endl;
      cout &lt;&lt; &quot;--------------------------------------&quot; &lt;&lt; endl;
      cout &lt;&lt; &quot;Name: &quot;;
      cin.getline(name,20);
      cout &lt;&lt; &quot;Vorname: &quot;;
      cin.getline(vname,20);
      cout &lt;&lt; &quot;Strasse (Name&amp;Nr): &quot;;
      cin.getline(str,30);
      cout &lt;&lt; &quot;PLZ: &quot;;
      cin.getline(plz,7);
      cout &lt;&lt; &quot;Telefon: &quot;;
      cin.getline(telefon,20);
      cout &lt;&lt; &quot;Kundennummer eingeben: &quot;;
      cin.getline(kundennr,7);
      cout &lt;&lt; &quot;--------------------------------------&quot; &lt;&lt; endl;
      fstream schreib;
      schreib.open(&quot;kunde.txt&quot;, ios::app | ios::out);
      schreib &lt;&lt; name &lt;&lt; &quot;\t&quot; &lt;&lt; vname &lt;&lt; &quot;\t&quot; &lt;&lt; str &lt;&lt; &quot;\t&quot; &lt;&lt; plz &lt;&lt; &quot;\t&quot; &lt;&lt; telefon &lt;&lt; &quot;\t&quot; &lt;&lt; kundennr &lt;&lt; endl; 
      schreib.close();
}
}
//...
</code></pre>
<p>wenn man das jetzt so ausfuehrt dann ueberspringt es irgendwie das cin.getline von &quot;name&quot;. dh in console steht da:&quot;Name:Vorname:&quot; und jetzt kann ich erst was eingeben. es schreibt zwar das cout &lt;&lt; &quot;Name&quot; aber das cin.getline ueberspringt es. nach rumprobieren kam ich darauf das es an dem</p>
<pre><code class="language-cpp">cin &gt;&gt; auswahl;
</code></pre>
<p>liegt. wenn ich das wegmache(und die if-schleife natuerlich) dann laeuft es wunderbar.<br />
genauso geht es auch wenn ich die main so lass wie sie oben ist aber ich in der &quot;void CKunde::daten_schreiben(void)&quot; alles mit cin statt cin.getline mache. das cin.getline brauch ich aber(wegen leerzeichen usw.).</p>
<p>ich hoffe ich konnt das einigermaßen verstaendlich ausdruecken was ich mein <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/topic/120966/ueberspringt-cin-zeile</link><generator>RSS for Node</generator><lastBuildDate>Sat, 22 Aug 2026 13:02:45 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/120966.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 18 Sep 2005 12:32:57 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to ueberspringt cin zeile on Sun, 18 Sep 2005 12:32:57 GMT]]></title><description><![CDATA[<p>hallo,<br />
hab ein problem mit cin bzw cin.getline.<br />
das ist ein einfaches eingeben/ausgeben aus txtdatei-programm:</p>
<p>die main</p>
<pre><code class="language-cpp">#include &quot;cperson.h&quot;
#include &quot;ckunde.h&quot;

void main (void)
{
CKunde k[100];
int auswahl;
int i=0;
cout &lt;&lt; &quot;Willkommen&quot; &lt;&lt; endl;
cout &lt;&lt; &quot;Was wollen Sie machen ?&quot; &lt;&lt; endl;
cout &lt;&lt; &quot;1. Kunde schreiben&quot; &lt;&lt; endl;
cout &lt;&lt; &quot;2. Kunde lesen&quot; &lt;&lt; endl;
cin &gt;&gt; auswahl;
if(auswahl == 1)
{
	k[i].daten_schreiben();
         i++;
}
}
</code></pre>
<p>die kunde.cpp</p>
<pre><code class="language-cpp">#include &quot;CKunde.h&quot;

CKunde::CKunde(void)
{

//....

void CKunde::daten_schreiben(void)
{
      cout &lt;&lt; &quot;--------------------------------------&quot; &lt;&lt; endl;
      cout &lt;&lt; &quot;Eingabe Daten&quot; &lt;&lt; endl;
      cout &lt;&lt; &quot;--------------------------------------&quot; &lt;&lt; endl;
      cout &lt;&lt; &quot;Name: &quot;;
      cin.getline(name,20);
      cout &lt;&lt; &quot;Vorname: &quot;;
      cin.getline(vname,20);
      cout &lt;&lt; &quot;Strasse (Name&amp;Nr): &quot;;
      cin.getline(str,30);
      cout &lt;&lt; &quot;PLZ: &quot;;
      cin.getline(plz,7);
      cout &lt;&lt; &quot;Telefon: &quot;;
      cin.getline(telefon,20);
      cout &lt;&lt; &quot;Kundennummer eingeben: &quot;;
      cin.getline(kundennr,7);
      cout &lt;&lt; &quot;--------------------------------------&quot; &lt;&lt; endl;
      fstream schreib;
      schreib.open(&quot;kunde.txt&quot;, ios::app | ios::out);
      schreib &lt;&lt; name &lt;&lt; &quot;\t&quot; &lt;&lt; vname &lt;&lt; &quot;\t&quot; &lt;&lt; str &lt;&lt; &quot;\t&quot; &lt;&lt; plz &lt;&lt; &quot;\t&quot; &lt;&lt; telefon &lt;&lt; &quot;\t&quot; &lt;&lt; kundennr &lt;&lt; endl; 
      schreib.close();
}
}
//...
</code></pre>
<p>wenn man das jetzt so ausfuehrt dann ueberspringt es irgendwie das cin.getline von &quot;name&quot;. dh in console steht da:&quot;Name:Vorname:&quot; und jetzt kann ich erst was eingeben. es schreibt zwar das cout &lt;&lt; &quot;Name&quot; aber das cin.getline ueberspringt es. nach rumprobieren kam ich darauf das es an dem</p>
<pre><code class="language-cpp">cin &gt;&gt; auswahl;
</code></pre>
<p>liegt. wenn ich das wegmache(und die if-schleife natuerlich) dann laeuft es wunderbar.<br />
genauso geht es auch wenn ich die main so lass wie sie oben ist aber ich in der &quot;void CKunde::daten_schreiben(void)&quot; alles mit cin statt cin.getline mache. das cin.getline brauch ich aber(wegen leerzeichen usw.).</p>
<p>ich hoffe ich konnt das einigermaßen verstaendlich ausdruecken was ich mein <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/874868</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/874868</guid><dc:creator><![CDATA[keinplan1337]]></dc:creator><pubDate>Sun, 18 Sep 2005 12:32:57 GMT</pubDate></item><item><title><![CDATA[Reply to ueberspringt cin zeile on Sun, 18 Sep 2005 12:44:51 GMT]]></title><description><![CDATA[<p>Lies diesen Post <a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-120962.html" rel="nofollow">hier</a>. Dein Problem ist das gleiche.</p>
<p>Caipi</p>
]]></description><link>https://www.c-plusplus.net/forum/post/874881</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/874881</guid><dc:creator><![CDATA[Caipi]]></dc:creator><pubDate>Sun, 18 Sep 2005 12:44:51 GMT</pubDate></item><item><title><![CDATA[Reply to ueberspringt cin zeile on Sun, 18 Sep 2005 12:47:12 GMT]]></title><description><![CDATA[<p>ja schon hab ich auch gelesen nach dem ich fertig war.</p>
<p>cin.clear(); cin.sync(); hilft mir jedoch auch nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/874885</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/874885</guid><dc:creator><![CDATA[keinplan1337]]></dc:creator><pubDate>Sun, 18 Sep 2005 12:47:12 GMT</pubDate></item><item><title><![CDATA[Reply to ueberspringt cin zeile on Sun, 18 Sep 2005 12:54:53 GMT]]></title><description><![CDATA[<p>aber mit dem cin.get() gehts</p>
<p>danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/874895</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/874895</guid><dc:creator><![CDATA[keinplan1337]]></dc:creator><pubDate>Sun, 18 Sep 2005 12:54:53 GMT</pubDate></item><item><title><![CDATA[Reply to ueberspringt cin zeile on Sun, 18 Sep 2005 12:58:35 GMT]]></title><description><![CDATA[<p>keinplan1337 schrieb:</p>
<blockquote>
<p>cin.clear(); cin.sync(); hilft mir jedoch auch nicht.</p>
</blockquote>
<p>Warum? Gleiches Problem wie vorher?<br />
Sollte eigentlich funktionieren, da cin.clear(); eventuelle Fehlerbits und cin.sync() den Eingabepuffer löscht.</p>
<p>Ansonsten kannst du die restlichen Zeichen im Puffer auch <a href="http://www.cppreference.com/cppio/ignore.html" rel="nofollow">ignorieren</a>.<br />
Schreibe nach cin &gt;&gt; auswahl;</p>
<pre><code class="language-cpp">cin.ignore(cin.rdbuf()-&gt;in_avail());
</code></pre>
<p>Btw: Hast du dir auch den Link angesehen? (<a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-111042.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-111042.html</a>).</p>
<p>Caipi</p>
]]></description><link>https://www.c-plusplus.net/forum/post/874899</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/874899</guid><dc:creator><![CDATA[Caipi]]></dc:creator><pubDate>Sun, 18 Sep 2005 12:58:35 GMT</pubDate></item><item><title><![CDATA[Reply to ueberspringt cin zeile on Sun, 18 Sep 2005 13:07:02 GMT]]></title><description><![CDATA[<p>ja gleiches problem und ja ich hab es mir durchgelesen.</p>
<p>mit clear(),sync() gehts auch nich. im gegenteil es gibt mir alle cout sachen aus aber ich kann nirgens was eingeben. also es steht &quot;Name:Vorname:Strasse....usw&quot; da und das porg endet.</p>
<p>mit ignore() gehts auch .. mit cin.get() vor dem cin.getline() aber auch.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/874906</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/874906</guid><dc:creator><![CDATA[keinplan1337]]></dc:creator><pubDate>Sun, 18 Sep 2005 13:07:02 GMT</pubDate></item><item><title><![CDATA[Reply to ueberspringt cin zeile on Sun, 18 Sep 2005 13:37:45 GMT]]></title><description><![CDATA[<p>Probier doch einfach mal das Ende des Ausgabestreams anzugeben.<br />
Soll heißen:</p>
<pre><code class="language-cpp">cout &lt;&lt; &quot;Name: &quot; &lt;&lt; flush;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/874935</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/874935</guid><dc:creator><![CDATA[Richie_Gecco]]></dc:creator><pubDate>Sun, 18 Sep 2005 13:37:45 GMT</pubDate></item></channel></rss>