<?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[[solved] string-array]]></title><description><![CDATA[<p>hi!</p>
<p>kurze frage:<br />
warum geht sowas hier nicht? steh auf der leitung.</p>
<pre><code class="language-cpp">string **stringArray()
{
    string *note[5];
    note[0] = new string( &quot;hallo1&quot; );
    note[1] = new string( &quot;hallo2&quot; );
    note[2] = new string( &quot;hallo3&quot; );
    note[3] = new string( &quot;hallo4&quot; );
    note[4] = new string( &quot;hallo5&quot; );

    for( int i = 0; i &lt; 5; i++ )
        cout &lt;&lt; ( *note[i] ) &lt;&lt; endl;

    return note;
}

...

    string **temp = stringArray();

    for( int i = 0; i &lt; 5; i++ )
        cout &lt;&lt; ( *temp[i] ) &lt;&lt; endl;  // erster string wird korrekt ausgegeben, dann stürzt das programm ab.
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/170430/solved-string-array</link><generator>RSS for Node</generator><lastBuildDate>Thu, 17 Sep 2026 02:48:55 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/170430.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 15 Jan 2007 20:29:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [solved] string-array on Thu, 20 Mar 2008 09:37:29 GMT]]></title><description><![CDATA[<p>hi!</p>
<p>kurze frage:<br />
warum geht sowas hier nicht? steh auf der leitung.</p>
<pre><code class="language-cpp">string **stringArray()
{
    string *note[5];
    note[0] = new string( &quot;hallo1&quot; );
    note[1] = new string( &quot;hallo2&quot; );
    note[2] = new string( &quot;hallo3&quot; );
    note[3] = new string( &quot;hallo4&quot; );
    note[4] = new string( &quot;hallo5&quot; );

    for( int i = 0; i &lt; 5; i++ )
        cout &lt;&lt; ( *note[i] ) &lt;&lt; endl;

    return note;
}

...

    string **temp = stringArray();

    for( int i = 0; i &lt; 5; i++ )
        cout &lt;&lt; ( *temp[i] ) &lt;&lt; endl;  // erster string wird korrekt ausgegeben, dann stürzt das programm ab.
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1210470</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1210470</guid><dc:creator><![CDATA[iko79]]></dc:creator><pubDate>Thu, 20 Mar 2008 09:37:29 GMT</pubDate></item><item><title><![CDATA[Reply to [solved] string-array on Mon, 15 Jan 2007 20:33:30 GMT]]></title><description><![CDATA[<p>iko79 schrieb:</p>
<blockquote>
<p>warum geht sowas hier nicht?</p>
</blockquote>
<p>Weil Du einen Zeiger auf ein lokales Stack-Objekt zurückgibst und verwendest, nachdem das Objekt vom Stack geschoben worden ist.</p>
<p>Was soll eigentlich die Sache mit den verschachtelten Zeigern?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1210473</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1210473</guid><dc:creator><![CDATA[Konrad Rudolph]]></dc:creator><pubDate>Mon, 15 Jan 2007 20:33:30 GMT</pubDate></item><item><title><![CDATA[Reply to [solved] string-array on Mon, 15 Jan 2007 20:47:35 GMT]]></title><description><![CDATA[<p>du müsstest in stringArray() vor note[..] = ... immer ein &quot;sternchen&quot; setzen, z.B.<br />
*note[0] = new string( &quot;hallo1&quot; );</p>
<p>logisch, da du ja einen &quot;doppelzeiger&quot; hast (zeiger auf zeiger), musst du auch doppelt dereferenzieren.</p>
<p>mfg,<br />
julian</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1210478</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1210478</guid><dc:creator><![CDATA[Julian__]]></dc:creator><pubDate>Mon, 15 Jan 2007 20:47:35 GMT</pubDate></item><item><title><![CDATA[Reply to [solved] string-array on Mon, 15 Jan 2007 20:52:48 GMT]]></title><description><![CDATA[<p>Julian__ schrieb:</p>
<blockquote>
<p>du müsstest in stringArray() vor note[..] = ... immer ein &quot;sternchen&quot; setzen, z.B.<br />
*note[0] = new string( &quot;hallo1&quot; );</p>
<p>logisch, da du ja einen &quot;doppelzeiger&quot; hast (zeiger auf zeiger), musst du auch doppelt dereferenzieren.</p>
</blockquote>
<p>Das klappt nicht, dann bräuchte er Dreifachzeiger. Der &quot;Doppelzeiger&quot; in der Typensignatur geht ja schon für das C-Array rauf.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1210482</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1210482</guid><dc:creator><![CDATA[Konrad Rudolph]]></dc:creator><pubDate>Mon, 15 Jan 2007 20:52:48 GMT</pubDate></item><item><title><![CDATA[Reply to [solved] string-array on Mon, 15 Jan 2007 21:02:01 GMT]]></title><description><![CDATA[<p>Konrad Rudolph schrieb:</p>
<blockquote>
<p>Was soll eigentlich die Sache mit den verschachtelten Zeigern?</p>
</blockquote>
<p>wie meinst? naja, is halt nur 'n beispiel für ein pointer-array... wieso?</p>
<p>wie kann ma in c++ sonst a pointer-array zurückgeben?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1210489</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1210489</guid><dc:creator><![CDATA[iko79]]></dc:creator><pubDate>Mon, 15 Jan 2007 21:02:01 GMT</pubDate></item><item><title><![CDATA[Reply to [solved] string-array on Tue, 16 Jan 2007 14:31:07 GMT]]></title><description><![CDATA[<p>iko79 schrieb:</p>
<blockquote>
<p>wie kann ma in c++ sonst a pointer-array zurückgeben?</p>
</blockquote>
<p>Das ist schon in Ordnung so. Aber wozu überhaupt das Zeiger-Array?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1210812</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1210812</guid><dc:creator><![CDATA[Konrad Rudolph]]></dc:creator><pubDate>Tue, 16 Jan 2007 14:31:07 GMT</pubDate></item><item><title><![CDATA[Reply to [solved] string-array on Thu, 20 Mar 2008 09:35:57 GMT]]></title><description><![CDATA[<p>naja, sowas brauch i halt manchmal... wenn i ein array rigendwelcher objekte hab dann arbeit' i ja eher mit pointern auf diese objekte als mit den objekten selbst genauso wie ich als funktionsparameter lieber pointer übergeb als das das gesamte objekt, aber das brauch i euch ja sicher net erzählen...<br />
sorry, aber i glaub i versteh die frage net ganz... meinst du jetz <strong>in dem speziellen fall</strong>? da machts natürlich keinen sinn. is wie gesagt nur 'n beispiel zu demonstrationszwecken, damit i net meinen kompletten sourcecode hier posten muss.</p>
<p>iko79 schrieb:</p>
<blockquote>
<p>wie kann ma in c++ sonst a pointer-array zurückgeben?</p>
</blockquote>
<p>was i damit gemeint hab ist: wie muss ich obiges beispiel umändern, damits funktioniert? wie geb ich in c++ a pointer-array zurück? durch das jahrelange c# hab i irgendwie 's programmieren verlernt <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1210873</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1210873</guid><dc:creator><![CDATA[iko79]]></dc:creator><pubDate>Thu, 20 Mar 2008 09:35:57 GMT</pubDate></item><item><title><![CDATA[Reply to [solved] string-array on Tue, 16 Jan 2007 16:24:55 GMT]]></title><description><![CDATA[<p>Konrad Rudolph schrieb:</p>
<blockquote>
<p>Julian__ schrieb:</p>
<blockquote>
<p>du müsstest in stringArray() vor note[..] = ... immer ein &quot;sternchen&quot; setzen, z.B.<br />
*note[0] = new string( &quot;hallo1&quot; );</p>
<p>logisch, da du ja einen &quot;doppelzeiger&quot; hast (zeiger auf zeiger), musst du auch doppelt dereferenzieren.</p>
</blockquote>
<p>Das klappt nicht, dann bräuchte er Dreifachzeiger. Der &quot;Doppelzeiger&quot; in der Typensignatur geht ja schon für das C-Array rauf.</p>
</blockquote>
<p>...stimmt, sorry. ich hatte es nur schnell überflogen und gleich die erstbeste (und -dümmste) idee gepostet.</p>
<p>mfg,<br />
julian</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1210882</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1210882</guid><dc:creator><![CDATA[Julian__]]></dc:creator><pubDate>Tue, 16 Jan 2007 16:24:55 GMT</pubDate></item><item><title><![CDATA[Reply to [solved] string-array on Tue, 16 Jan 2007 16:45:55 GMT]]></title><description><![CDATA[<p>Dein Rückgabetyp ist schon korrekt. Du mußt nur dein Array anders erstellen.</p>
<pre><code class="language-cpp">// statt
string *note[5];
// dann
string** note = new string*[5];
</code></pre>
<p>Ich würde hier aber lieber einen vector nehmen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1210902</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1210902</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Tue, 16 Jan 2007 16:45:55 GMT</pubDate></item><item><title><![CDATA[Reply to [solved] string-array on Tue, 16 Jan 2007 17:57:39 GMT]]></title><description><![CDATA[<p>warum nicht einen vector&lt;string&gt; verwenden ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1210934</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1210934</guid><dc:creator><![CDATA[ronny]]></dc:creator><pubDate>Tue, 16 Jan 2007 17:57:39 GMT</pubDate></item><item><title><![CDATA[Reply to [solved] string-array on Tue, 16 Jan 2007 18:00:53 GMT]]></title><description><![CDATA[<p>sagte ich doch. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1210937</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1210937</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Tue, 16 Jan 2007 18:00:53 GMT</pubDate></item><item><title><![CDATA[Reply to [solved] string-array on Tue, 16 Jan 2007 22:44:23 GMT]]></title><description><![CDATA[<p>Braunstein schrieb:</p>
<blockquote>
<p>Du mußt nur dein Array anders erstellen.</p>
</blockquote>
<p>das war's, danke vielmals!!</p>
<p>Braunstein schrieb:</p>
<blockquote>
<p>Ich würde hier aber lieber einen vector nehmen.</p>
</blockquote>
<p>hast schon recht, aber solche fehler lassen mi dann doch net ruhig schlafen - weil i mir denk &quot;das muss doch gehen&quot;... ging mir auch ein wenig ums prinzip bei der frage.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1211054</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1211054</guid><dc:creator><![CDATA[iko79]]></dc:creator><pubDate>Tue, 16 Jan 2007 22:44:23 GMT</pubDate></item><item><title><![CDATA[Reply to [solved] string-array on Wed, 17 Jan 2007 07:28:22 GMT]]></title><description><![CDATA[<p>iko79 schrieb:</p>
<blockquote>
<p>...- weil i mir denk &quot;das muss doch gehen&quot;... ging mir auch ein wenig ums prinzip bei der frage.</p>
</blockquote>
<p>Gründlichkeit: Guter Ansatz für einen Programmierer !<br />
(Wenn er dann zusätzlich noch &quot;schnell zusammenhauen&quot; kann, ist er perfekt <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> )</p>
<p>Gruß,</p>
<p>Simon2.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1211115</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1211115</guid><dc:creator><![CDATA[Simon2]]></dc:creator><pubDate>Wed, 17 Jan 2007 07:28:22 GMT</pubDate></item><item><title><![CDATA[Reply to [solved] string-array on Wed, 17 Jan 2007 08:05:02 GMT]]></title><description><![CDATA[<p>iko79 schrieb:</p>
<blockquote>
<p>das war's, danke vielmals!!</p>
</blockquote>
<p>Bei diesem Ansatz aber bitte noch an ein delete[] an passender Stelle denken.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1211130</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1211130</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Wed, 17 Jan 2007 08:05:02 GMT</pubDate></item></channel></rss>