<?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[Anfängerfrage]]></title><description><![CDATA[<p>Hallo.</p>
<p>Hab eine Frage und zwar:</p>
<p>wenn ich einen char* erstelle z.b.</p>
<pre><code>char* test = &quot;lang&quot;;
</code></pre>
<p>und im nächsten Schritt ändere:</p>
<pre><code>test = &quot;länger&quot;;
</code></pre>
<p>kann ich dann etwas im Speicher überschreiben, da das Array ja größer ist<br />
als das am Anfang initialisierte Array. Oder kann da nichts passieren?</p>
<p>Gruß Chris</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/243397/anfängerfrage</link><generator>RSS for Node</generator><lastBuildDate>Sun, 20 Sep 2026 03:27:57 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/243397.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 16 Jun 2009 10:36:55 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Anfängerfrage on Tue, 16 Jun 2009 10:46:44 GMT]]></title><description><![CDATA[<p>Hallo.</p>
<p>Hab eine Frage und zwar:</p>
<p>wenn ich einen char* erstelle z.b.</p>
<pre><code>char* test = &quot;lang&quot;;
</code></pre>
<p>und im nächsten Schritt ändere:</p>
<pre><code>test = &quot;länger&quot;;
</code></pre>
<p>kann ich dann etwas im Speicher überschreiben, da das Array ja größer ist<br />
als das am Anfang initialisierte Array. Oder kann da nichts passieren?</p>
<p>Gruß Chris</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1727482</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1727482</guid><dc:creator><![CDATA[callmechris]]></dc:creator><pubDate>Tue, 16 Jun 2009 10:46:44 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerfrage on Tue, 16 Jun 2009 10:40:38 GMT]]></title><description><![CDATA[<p>callmechris schrieb:</p>
<blockquote>
<p>...und im nächsten Schritt ändere...</p>
</blockquote>
<p>Ist nicht legal. Du hast nur einen Zeiger erstellt, keinen Speicher für das Objekt. Das gehört sozusagen dem Compiler.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1727483</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1727483</guid><dc:creator><![CDATA[Illegal0r]]></dc:creator><pubDate>Tue, 16 Jun 2009 10:40:38 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerfrage on Tue, 16 Jun 2009 11:01:22 GMT]]></title><description><![CDATA[<blockquote>
<p>st nicht legal. Du hast nur einen Zeiger erstellt, keinen Speicher für das Objekt. Das gehört sozusagen dem Compiler.</p>
</blockquote>
<p>Aber ich kann ja trotzdem auf den String zugreifen und ihn ausgeben oder verändern, d.h. doch er liegt irgendwo im Speicher. Er ist halt automatisch weg, wenn das Programm die Methode verlässt. Aber trotzdem schreibe ich doch bei der Veränderung des Strings irgendwo im Speicher rum oder?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1727498</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1727498</guid><dc:creator><![CDATA[callmechris]]></dc:creator><pubDate>Tue, 16 Jun 2009 11:01:22 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerfrage on Tue, 16 Jun 2009 11:02:12 GMT]]></title><description><![CDATA[<p>So, wie du das geschrieben hast, kannst du nix kaputtmachen. Du änderst ja nix, Du lässt nur den Zeiger 'test' auf ein anderes Literal zeigen. Und das ist legal, aber irgendwie unsinnig, weil das zuerst zugewiesene Literal jetzt nicht mehr erreichbar ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1727499</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1727499</guid><dc:creator><![CDATA[Belli]]></dc:creator><pubDate>Tue, 16 Jun 2009 11:02:12 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerfrage on Tue, 16 Jun 2009 11:05:41 GMT]]></title><description><![CDATA[<p>callmechris schrieb:</p>
<blockquote>
<p>Aber ich kann ja trotzdem auf den String zugreifen und ihn ausgeben oder verändern</p>
</blockquote>
<p>Nein, verändern ist verboten:</p>
<p>char *test = &quot;lang&quot;;<br />
test[0] = 'L';</p>
<p>kann bei Programmausführung zu Problemen führen und sollte man deshalb unterlassen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1727502</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1727502</guid><dc:creator><![CDATA[Belli]]></dc:creator><pubDate>Tue, 16 Jun 2009 11:05:41 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerfrage on Tue, 16 Jun 2009 12:52:32 GMT]]></title><description><![CDATA[<p>Aus diesem Grund sollten Stringliterale immer mit <code>const</code>  <code>char*</code> deklariert werden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1727601</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1727601</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Tue, 16 Jun 2009 12:52:32 GMT</pubDate></item></channel></rss>