<?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[Verständnisfrage zu cin.get]]></title><description><![CDATA[<p>Hallo, vielleicht kann mir hier jemand erklären warum &quot;cin.get&quot; so nicht funktioniert. Ich grübel darüber schon die ganze Zeit, &quot;cin &gt;&gt; inc&quot; funktioniert ja allerdings möchte ich mehr als bis zum ersten Leerzeichen in die Textdatei schreiben. Hat das möglicherweise etwas mit dem char Array zu tun?<br />
Vielen Dank.</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;fstream&gt;

using namespace std;

int main (int argc, char *argv[])
{
	int auswahl;
	fstream f;
	char inc[55];

    cout &lt;&lt; &quot;[1] Eingabe in Textdatei speichern&quot; &lt;&lt; endl &lt;&lt; endl;
	cout &lt;&lt; &quot;Deine Eingabe: &quot;;
     cin  &gt;&gt; auswahl;

     switch ( auswahl ) 
	{
        case 1:
			cout &lt;&lt; &quot;Deine Eingabe: &quot;;
			     // Warum geht hier cin.get nicht?
		      cin.get (inc, 54);
		      //cin &gt;&gt; inc;

	          f.open(&quot;config.ini&quot;, ios::out);
	          f &lt;&lt; inc &lt;&lt; endl;
   		      f.close();
		     exit(1);
           break;
        default:
            cout &lt;&lt; &quot;Falsche Eingabe.&quot;;
		  exit(2);
        }

 return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/122778/verständnisfrage-zu-cin-get</link><generator>RSS for Node</generator><lastBuildDate>Sun, 23 Aug 2026 07:17:50 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/122778.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 09 Oct 2005 23:25:43 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Verständnisfrage zu cin.get on Sun, 09 Oct 2005 23:28:50 GMT]]></title><description><![CDATA[<p>Hallo, vielleicht kann mir hier jemand erklären warum &quot;cin.get&quot; so nicht funktioniert. Ich grübel darüber schon die ganze Zeit, &quot;cin &gt;&gt; inc&quot; funktioniert ja allerdings möchte ich mehr als bis zum ersten Leerzeichen in die Textdatei schreiben. Hat das möglicherweise etwas mit dem char Array zu tun?<br />
Vielen Dank.</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;fstream&gt;

using namespace std;

int main (int argc, char *argv[])
{
	int auswahl;
	fstream f;
	char inc[55];

    cout &lt;&lt; &quot;[1] Eingabe in Textdatei speichern&quot; &lt;&lt; endl &lt;&lt; endl;
	cout &lt;&lt; &quot;Deine Eingabe: &quot;;
     cin  &gt;&gt; auswahl;

     switch ( auswahl ) 
	{
        case 1:
			cout &lt;&lt; &quot;Deine Eingabe: &quot;;
			     // Warum geht hier cin.get nicht?
		      cin.get (inc, 54);
		      //cin &gt;&gt; inc;

	          f.open(&quot;config.ini&quot;, ios::out);
	          f &lt;&lt; inc &lt;&lt; endl;
   		      f.close();
		     exit(1);
           break;
        default:
            cout &lt;&lt; &quot;Falsche Eingabe.&quot;;
		  exit(2);
        }

 return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/888494</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/888494</guid><dc:creator><![CDATA[max28]]></dc:creator><pubDate>Sun, 09 Oct 2005 23:28:50 GMT</pubDate></item><item><title><![CDATA[Reply to Verständnisfrage zu cin.get on Mon, 10 Oct 2005 06:23:48 GMT]]></title><description><![CDATA[<p>cin.get() liest AFAIK nur ein einzelnes Zeichen ein, du willst offensichtlich eine Zeichenkette einlesen, mach das über getline(cin, inc)<br />
Btw. Du solltest sowieso std::string verwenden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/888541</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/888541</guid><dc:creator><![CDATA[GPC]]></dc:creator><pubDate>Mon, 10 Oct 2005 06:23:48 GMT</pubDate></item><item><title><![CDATA[Reply to Verständnisfrage zu cin.get on Mon, 10 Oct 2005 09:14:53 GMT]]></title><description><![CDATA[<p>Vielen Dank für die Antwort.<br />
Ich werd es mal mit string ausprobieren.<br />
Aber ich kann mit cin.get (inc, 54); eine komplette Zeile einlesen, leider nur außerhalb der switch Anweisung, aus irgendeinem Grund funktioniert das innerhalb nicht.<br />
So funktioniert die Eingabe einer ganzen Zeile:</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;string&gt;

using namespace std;

int main (int argc, char *argv[])
{
	int auswahl;
	fstream f;
	char inc[55];

	  cin.get (inc, 54);

	          f.open(&quot;config.ini&quot;, ios::out);
	          f &lt;&lt; inc &lt;&lt; endl;
   		      f.close();
		     exit(1);
</code></pre>
<p>Edit: Ich habe das selbe mal mit string und getline ausprobiert, ich kann zwar etwas eingeben, allerdings wird nichts in der Textdatei gespeichert. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/888629</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/888629</guid><dc:creator><![CDATA[max28]]></dc:creator><pubDate>Mon, 10 Oct 2005 09:14:53 GMT</pubDate></item></channel></rss>