<?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 addieren]]></title><description><![CDATA[<p>Hallo,<br />
Ich möchte einen String und ein null-terminiertes Char-Array aneinanderhängen.</p>
<p>string string1=&quot;Text&quot;;<br />
char chararray1[3];<br />
chararray1[0]='a';<br />
chararray1[1]='b';<br />
chararray1[2]=0;</p>
<p>string1=string1+chararray1;</p>
<p>Geht das? Normalerweise müsst ich das Array doch erst umwandeln, oder?<br />
Das möchte ich nicht machen, weil ich in einer Schleife bin.<br />
Und die Umwandlung mit &quot;string string2(chararray1)&quot; geht ja nur einmal bei der Definierung.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/192801/string-addieren</link><generator>RSS for Node</generator><lastBuildDate>Sun, 27 Sep 2026 15:24:57 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/192801.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 18 Sep 2007 20:23:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to string addieren on Tue, 18 Sep 2007 20:23:00 GMT]]></title><description><![CDATA[<p>Hallo,<br />
Ich möchte einen String und ein null-terminiertes Char-Array aneinanderhängen.</p>
<p>string string1=&quot;Text&quot;;<br />
char chararray1[3];<br />
chararray1[0]='a';<br />
chararray1[1]='b';<br />
chararray1[2]=0;</p>
<p>string1=string1+chararray1;</p>
<p>Geht das? Normalerweise müsst ich das Array doch erst umwandeln, oder?<br />
Das möchte ich nicht machen, weil ich in einer Schleife bin.<br />
Und die Umwandlung mit &quot;string string2(chararray1)&quot; geht ja nur einmal bei der Definierung.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1368050</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1368050</guid><dc:creator><![CDATA[krischan111]]></dc:creator><pubDate>Tue, 18 Sep 2007 20:23:00 GMT</pubDate></item><item><title><![CDATA[Reply to string addieren on Tue, 18 Sep 2007 20:28:14 GMT]]></title><description><![CDATA[<p>&quot;Definierung&quot; gibt es nicht. du meinst wohl &quot;Definition&quot;.<br />
es spräche nichts dagegen, die definition von string2 in die schleife zu packen:</p>
<pre><code class="language-cpp">while (...)
{
   string string2(chararray1);
   string1 += string2;

}
</code></pre>
<p>aber was du fragst, hättest du auch selbst herausfinden können, indem du einfach deinen compiler ein stückchen testcode kompilieren lässt.</p>
<pre><code class="language-cpp">string1 = string1 + chararray1;//problemlos möglich, solange chararray1 ein NTBS ist (null terminierter zeichenstring)
//oder:
string1 += chararray1;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1368054</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1368054</guid><dc:creator><![CDATA[queer_boy]]></dc:creator><pubDate>Tue, 18 Sep 2007 20:28:14 GMT</pubDate></item><item><title><![CDATA[Reply to string addieren on Tue, 18 Sep 2007 20:30:12 GMT]]></title><description><![CDATA[<p>krischan111 schrieb:</p>
<blockquote>
<p>char chararray1[3];<br />
chararray1[0]='a';<br />
chararray1[1]='b';<br />
chararray1[2]=0;</p>
</blockquote>
<p>noch ein letzter hinweis, dann war's:<br />
die folgende syntax ist auch erlaubt.</p>
<pre><code class="language-cpp">char chararray1[3] = &quot;ab&quot;; //&quot;ab&quot; ist ein stringliteral, das automatisch eine \0 am ende hat
//noch einfacher:
char chararray1[] = &quot;ab&quot;; //die länge des arrays kann der compiler auch automatisch bestimmen.
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1368056</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1368056</guid><dc:creator><![CDATA[queer_boy]]></dc:creator><pubDate>Tue, 18 Sep 2007 20:30:12 GMT</pubDate></item><item><title><![CDATA[Reply to string addieren on Tue, 18 Sep 2007 20:42:43 GMT]]></title><description><![CDATA[<p>Jupp, danke.</p>
<p>Hat mich bloß gewundert, dass ich kein Tutorial dazu gefunden hab.<br />
<a href="http://www.cppreference.com/cppstring/string_operators.html" rel="nofollow">http://www.cppreference.com/cppstring/string_operators.html</a> listet strings, chars und c_strings auf, aber kein chararray. Nagut!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1368071</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1368071</guid><dc:creator><![CDATA[krischan111]]></dc:creator><pubDate>Tue, 18 Sep 2007 20:42:43 GMT</pubDate></item><item><title><![CDATA[Reply to string addieren on Tue, 18 Sep 2007 20:46:14 GMT]]></title><description><![CDATA[<p>c-strings sind idR chararrays. zumindest können chararrays nach &quot;zeiger auf char&quot; konvertiert werden.</p>
<p>der begriff c-string bezieht sich nur darauf, dass am ende der zeichenkette eine '\0' steht, die sie terminiert. der allgemeine begriff dazu lautet NTBS (null terminated byte string). ein zeiger auf einen c-string ist immer nur ein zeiger auf ein char (=byte). und einen zeiger auf einen char kannst du auch in ein char-array zeigen lassen.</p>
<p>alles klar?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1368075</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1368075</guid><dc:creator><![CDATA[queer_boy]]></dc:creator><pubDate>Tue, 18 Sep 2007 20:46:14 GMT</pubDate></item></channel></rss>