<?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[string]]></title><description><![CDATA[<p>hallo</p>
<p>ich hab eine frage bzw ein problem mit &quot;string&quot;.</p>
<p>ich bin noch ziemlicher anfänger in C++ und wollte ein (konsolen-)programm schreiben das einen string einließt und diesen dann in eine datei schreibt.</p>
<p>wenn ichs aber so mach:</p>
<pre><code class="language-cpp">string text;
cin &gt;&gt; text;
</code></pre>
<p>dann is im string text immer nur der teil vor dem ersten leerzeichen also das erste wort.</p>
<p>ich habs schon geändert und so gehts jetzt:</p>
<pre><code class="language-cpp">char a;
string text;

while (a = getchar())
{
  if (a == '\n')
    break;
  text += a;
}
</code></pre>
<p>aber gibt es auch eine andere möglichkeit ?</p>
<p>danke,<br />
mick</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/158904/string</link><generator>RSS for Node</generator><lastBuildDate>Thu, 10 Sep 2026 07:47:26 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/158904.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 09 Sep 2006 21:13:37 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to string on Sat, 09 Sep 2006 21:13:37 GMT]]></title><description><![CDATA[<p>hallo</p>
<p>ich hab eine frage bzw ein problem mit &quot;string&quot;.</p>
<p>ich bin noch ziemlicher anfänger in C++ und wollte ein (konsolen-)programm schreiben das einen string einließt und diesen dann in eine datei schreibt.</p>
<p>wenn ichs aber so mach:</p>
<pre><code class="language-cpp">string text;
cin &gt;&gt; text;
</code></pre>
<p>dann is im string text immer nur der teil vor dem ersten leerzeichen also das erste wort.</p>
<p>ich habs schon geändert und so gehts jetzt:</p>
<pre><code class="language-cpp">char a;
string text;

while (a = getchar())
{
  if (a == '\n')
    break;
  text += a;
}
</code></pre>
<p>aber gibt es auch eine andere möglichkeit ?</p>
<p>danke,<br />
mick</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1134416</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1134416</guid><dc:creator><![CDATA[mick]]></dc:creator><pubDate>Sat, 09 Sep 2006 21:13:37 GMT</pubDate></item><item><title><![CDATA[Reply to string on Sat, 09 Sep 2006 21:18:08 GMT]]></title><description><![CDATA[<p>Such mal nach getline da gibts mehrere interesannte Informationen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1134418</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1134418</guid><dc:creator><![CDATA[Knuddlbaer]]></dc:creator><pubDate>Sat, 09 Sep 2006 21:18:08 GMT</pubDate></item><item><title><![CDATA[Reply to string on Sat, 09 Sep 2006 21:26:08 GMT]]></title><description><![CDATA[<p>danke<br />
genau sowas hab ich gesucht</p>
<p>mick</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1134419</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1134419</guid><dc:creator><![CDATA[mick]]></dc:creator><pubDate>Sat, 09 Sep 2006 21:26:08 GMT</pubDate></item></channel></rss>