<?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[std::string von char* initialisieren - terminierung]]></title><description><![CDATA[<p>Hallo,</p>
<p>kurze klarstellung. Die Referenz sagt</p>
<blockquote>
<pre><code class="language-cpp">string ( const char * s );
</code></pre>
<p>Content is initialized to a copy of the string formed by the null-terminated character sequence (C string) pointed by s. The length of the caracter sequence is determined by the first occurrence of a null character (as determined by traits.length(s)). This version can be used to initialize a string object using a string literal constant.</p>
</blockquote>
<p>Das heißt wenn mein char[] so aussieht:</p>
<pre><code class="language-cpp">char cstr[6] = {'a','b',0x0,'c','d', 0x0};
std::string str(cstr);
</code></pre>
<p>Dann ist der Inhalt von str = &quot;ab&quot; ?<br />
habe ich das korrekt verstanden?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/236176/std-string-von-char-initialisieren-terminierung</link><generator>RSS for Node</generator><lastBuildDate>Thu, 24 Sep 2026 02:19:00 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/236176.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 11 Mar 2009 16:33:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to std::string von char* initialisieren - terminierung on Wed, 11 Mar 2009 16:35:04 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>kurze klarstellung. Die Referenz sagt</p>
<blockquote>
<pre><code class="language-cpp">string ( const char * s );
</code></pre>
<p>Content is initialized to a copy of the string formed by the null-terminated character sequence (C string) pointed by s. The length of the caracter sequence is determined by the first occurrence of a null character (as determined by traits.length(s)). This version can be used to initialize a string object using a string literal constant.</p>
</blockquote>
<p>Das heißt wenn mein char[] so aussieht:</p>
<pre><code class="language-cpp">char cstr[6] = {'a','b',0x0,'c','d', 0x0};
std::string str(cstr);
</code></pre>
<p>Dann ist der Inhalt von str = &quot;ab&quot; ?<br />
habe ich das korrekt verstanden?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1678202</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1678202</guid><dc:creator><![CDATA[PhilippM]]></dc:creator><pubDate>Wed, 11 Mar 2009 16:35:04 GMT</pubDate></item><item><title><![CDATA[Reply to std::string von char* initialisieren - terminierung on Wed, 11 Mar 2009 16:35:36 GMT]]></title><description><![CDATA[<p>Ja, das hast du richtig verstanden. Bei C-Strings wird der Teil nach dem ersten Auftreten der Nullterminierung immer ignoriert, das gilt auch für die C-Funktionen, die mit <code>str</code> beginnen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1678204</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1678204</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Wed, 11 Mar 2009 16:35:36 GMT</pubDate></item><item><title><![CDATA[Reply to std::string von char* initialisieren - terminierung on Wed, 11 Mar 2009 16:35:51 GMT]]></title><description><![CDATA[<p>Exakt.</p>
<p>In C++ sind C-String (Char*) generell null-terminiert. Wenn du sowas machst wie const char* ab = &quot;AB&quot;; erstellt der Compiler im Grunde etwas wie: const char[] ab = { 'A', 'B', '\0' };<br />
('\0' == 0x0)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1678206</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1678206</guid><dc:creator><![CDATA[The-Kenny]]></dc:creator><pubDate>Wed, 11 Mar 2009 16:35:51 GMT</pubDate></item><item><title><![CDATA[Reply to std::string von char* initialisieren - terminierung on Wed, 11 Mar 2009 22:50:48 GMT]]></title><description><![CDATA[<p>Danke, alles klar!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1678410</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1678410</guid><dc:creator><![CDATA[PhilippM]]></dc:creator><pubDate>Wed, 11 Mar 2009 22:50:48 GMT</pubDate></item></channel></rss>