<?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[str = L&amp;quot;123456789&amp;quot; + L&#x27;0&#x27;;]]></title><description><![CDATA[<p>Hi, ist folgender Code valid oder kommt da Murks raus?</p>
<pre><code>std::wstring str;
	str = L&quot;123456789&quot; + L'0';
</code></pre>
<p>Zumindest bekomme ich teilweise Textfragmente aus anderen Strings ausgegeben. Vielleicht ist aber auch nur meine Anwendung zerschossen ;).</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/289443/str-l-quot-123456789-quot-l-0</link><generator>RSS for Node</generator><lastBuildDate>Wed, 19 Aug 2026 05:44:04 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/289443.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 05 Jul 2011 01:07:12 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to str = L&amp;quot;123456789&amp;quot; + L&#x27;0&#x27;; on Tue, 05 Jul 2011 01:07:12 GMT]]></title><description><![CDATA[<p>Hi, ist folgender Code valid oder kommt da Murks raus?</p>
<pre><code>std::wstring str;
	str = L&quot;123456789&quot; + L'0';
</code></pre>
<p>Zumindest bekomme ich teilweise Textfragmente aus anderen Strings ausgegeben. Vielleicht ist aber auch nur meine Anwendung zerschossen ;).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2088932</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2088932</guid><dc:creator><![CDATA[AmEnde]]></dc:creator><pubDate>Tue, 05 Jul 2011 01:07:12 GMT</pubDate></item><item><title><![CDATA[Reply to str = L&amp;quot;123456789&amp;quot; + L&#x27;0&#x27;; on Tue, 05 Jul 2011 01:12:02 GMT]]></title><description><![CDATA[<p>Achso, wenn ich mir mal den String über die gesamte Capacity ausgeben lasse sind dort auch teilweise Textfragmente von anderen Strings erkennbar. Wird hier der Speicherbereich nicht beim Anfordern mit z.B. 0 initialisert?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2088933</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2088933</guid><dc:creator><![CDATA[AmEnde]]></dc:creator><pubDate>Tue, 05 Jul 2011 01:12:02 GMT</pubDate></item><item><title><![CDATA[Reply to str = L&amp;quot;123456789&amp;quot; + L&#x27;0&#x27;; on Tue, 05 Jul 2011 02:18:07 GMT]]></title><description><![CDATA[<p>AmEnde schrieb:</p>
<blockquote>
<p>Hi, ist folgender Code valid oder kommt da Murks raus?</p>
</blockquote>
<p>Da kommt Murks raus.</p>
<p>Hintergrund ist, dass das Literal L&quot;123456789&quot; einen Zeiger auf die Adresse des ersten Elements zurückliefert.</p>
<p>Durch + L'0' wird keine Konkatenation ausgeführt sonder Zeigerarithmetik, d.h. du verschiebst den Zeiger um den Wert von L'0'.</p>
<p>Deine Variable str wird dann mit dem initialisiert, was an der resultierenden Speicherstelle zu finden ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2088939</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2088939</guid><dc:creator><![CDATA[hmpf]]></dc:creator><pubDate>Tue, 05 Jul 2011 02:18:07 GMT</pubDate></item><item><title><![CDATA[Reply to str = L&amp;quot;123456789&amp;quot; + L&#x27;0&#x27;; on Tue, 05 Jul 2011 12:16:58 GMT]]></title><description><![CDATA[<p>Seltsam, dass das der Compiler nicht schon bemängelt. Ein + L&quot;\0&quot;; wird ja auch als Fehler wegen Zeigeraddition angezeigt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2089073</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2089073</guid><dc:creator><![CDATA[AmEnde]]></dc:creator><pubDate>Tue, 05 Jul 2011 12:16:58 GMT</pubDate></item><item><title><![CDATA[Reply to str = L&amp;quot;123456789&amp;quot; + L&#x27;0&#x27;; on Tue, 05 Jul 2011 12:26:50 GMT]]></title><description><![CDATA[<p>AmEnde schrieb:</p>
<blockquote>
<p>Seltsam, dass das der Compiler nicht schon bemängelt. Ein + L&quot;\0&quot;; wird ja auch als Fehler wegen Zeigeraddition angezeigt.</p>
</blockquote>
<p>Ja, aber hier hast du (nach dem array-to-pointer-decay) <code>const wchar_t* + const wchar_t*</code> . Zwei Zeiger kannst du nicht addieren.</p>
<p>Hingegen sind mit <code>+ L'0'</code> die Typen <code>const wchar_t* + wchar_t</code> im Spiel. <code>wchar_t</code> ist ein integraler Typ und kann als solcher als Zeiger-Offset verwendet werden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2089078</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2089078</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Tue, 05 Jul 2011 12:26:50 GMT</pubDate></item><item><title><![CDATA[Reply to str = L&amp;quot;123456789&amp;quot; + L&#x27;0&#x27;; on Tue, 05 Jul 2011 13:06:28 GMT]]></title><description><![CDATA[<p>Da könnte zum Beispiel auch <code>str = L&quot;123456789&quot; + 3;</code> stehen (denn ein char-Literal ist auch nur eine Zahl), dann wird deutlich was da geschieht und warum der Compiler nicht meckert. Dann hätte str den Inhalt &quot;456789&quot;.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2089091</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2089091</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Tue, 05 Jul 2011 13:06:28 GMT</pubDate></item></channel></rss>