<?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[Strings in C-Strings umwandeln]]></title><description><![CDATA[<p>1. Wie kann ich Stringdaten in Charfelder umwandeln, wobei die Anzahl der benötigten C-Strings<br />
zum Zeitpunkt des Programmlaufs nicht bekannt ist, da die Anzahl der Strings sich erst im Laufe<br />
des Programms ergibt.</p>
<p>2. Die Strings sollen auf einen bestimmten C-String geschoben werden, der immer wieder neu<br />
belegt wird. So gesehen wird eigentlich nur ein Charfeld benötigt.</p>
<p>Lösung soll möglichst compilerunabhängig sein.</p>
<p>Heinrich</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/123181/strings-in-c-strings-umwandeln</link><generator>RSS for Node</generator><lastBuildDate>Sun, 23 Aug 2026 12:19:41 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/123181.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 13 Oct 2005 17:05:48 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Strings in C-Strings umwandeln on Thu, 13 Oct 2005 17:05:48 GMT]]></title><description><![CDATA[<p>1. Wie kann ich Stringdaten in Charfelder umwandeln, wobei die Anzahl der benötigten C-Strings<br />
zum Zeitpunkt des Programmlaufs nicht bekannt ist, da die Anzahl der Strings sich erst im Laufe<br />
des Programms ergibt.</p>
<p>2. Die Strings sollen auf einen bestimmten C-String geschoben werden, der immer wieder neu<br />
belegt wird. So gesehen wird eigentlich nur ein Charfeld benötigt.</p>
<p>Lösung soll möglichst compilerunabhängig sein.</p>
<p>Heinrich</p>
]]></description><link>https://www.c-plusplus.net/forum/post/891597</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/891597</guid><dc:creator><![CDATA[Heinrich]]></dc:creator><pubDate>Thu, 13 Oct 2005 17:05:48 GMT</pubDate></item><item><title><![CDATA[Reply to Strings in C-Strings umwandeln on Thu, 13 Oct 2005 18:41:16 GMT]]></title><description><![CDATA[<p>Komm zwar nicht ganz mit, aber so kriegt man ein Char-Array aus nem std::string</p>
<pre><code class="language-cpp">std::string str(&quot;Hallo Welt&quot;);
char cstr[] = str.c_str();
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/891690</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/891690</guid><dc:creator><![CDATA[GPC]]></dc:creator><pubDate>Thu, 13 Oct 2005 18:41:16 GMT</pubDate></item><item><title><![CDATA[Reply to Strings in C-Strings umwandeln on Thu, 13 Oct 2005 18:45:45 GMT]]></title><description><![CDATA[<p>GPC schrieb:</p>
<blockquote>
<pre><code class="language-cpp">char cstr[] = str.c_str();
</code></pre>
</blockquote>
<p>nee, klappt nicht ganz.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/891695</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/891695</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Thu, 13 Oct 2005 18:45:45 GMT</pubDate></item><item><title><![CDATA[Reply to Strings in C-Strings umwandeln on Thu, 13 Oct 2005 19:20:11 GMT]]></title><description><![CDATA[<p>Eh, was hab ich vergessen?</p>
<p>EDIT: Idee:</p>
<pre><code class="language-cpp">std::string str(&quot;Hallo Welt&quot;);

char *cstr = new char[str.size()];
strcpy(cstr, str.c_str());  //Echte Männer lieben das Risiko ;)
//..mit cstr arbeiten
delete [] cstr;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/891699</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/891699</guid><dc:creator><![CDATA[GPC]]></dc:creator><pubDate>Thu, 13 Oct 2005 19:20:11 GMT</pubDate></item><item><title><![CDATA[Reply to Strings in C-Strings umwandeln on Thu, 13 Oct 2005 20:44:17 GMT]]></title><description><![CDATA[<p>Wenn deine Standardlib strdup kennt, dann kannst es einfach so machen: char* p = strdup( myString.c_str() );<br />
ansonsten musst halt selbst Speicher anfordern und kopieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/891821</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/891821</guid><dc:creator><![CDATA[User---]]></dc:creator><pubDate>Thu, 13 Oct 2005 20:44:17 GMT</pubDate></item><item><title><![CDATA[Reply to Strings in C-Strings umwandeln on Thu, 13 Oct 2005 21:27:21 GMT]]></title><description><![CDATA[<p>User--- schrieb:</p>
<blockquote>
<p>Wenn deine Standardlib strdup kennt, dann kannst es einfach so machen: char* p = strdup( myString.c_str() );<br />
ansonsten musst halt selbst Speicher anfordern und kopieren.</p>
</blockquote>
<p>Machst du doch hier auch. Strdup fordert Speicher an, und wehe du free()st ihn nicht!</p>
<p>Bye, TGGC (<a href="http://tggc.tg.funpic.de/index.php?cat=4" rel="nofollow">Demo or Die</a>)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/891855</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/891855</guid><dc:creator><![CDATA[TGGC]]></dc:creator><pubDate>Thu, 13 Oct 2005 21:27:21 GMT</pubDate></item><item><title><![CDATA[Reply to Strings in C-Strings umwandeln on Thu, 13 Oct 2005 21:30:54 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">char *cstr = new char[str.size()];// +1 fehlt für die abschließende 0
strcpy(cstr, str.c_str()); //Echte Männer lieben das Risiko ;)
//..mit cstr arbeiten
delete [] cstr;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/891859</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/891859</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Thu, 13 Oct 2005 21:30:54 GMT</pubDate></item><item><title><![CDATA[Reply to Strings in C-Strings umwandeln on Thu, 13 Oct 2005 21:32:10 GMT]]></title><description><![CDATA[<p>echte männer nehmen std::vector.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/891860</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/891860</guid><dc:creator><![CDATA[Optimizer&amp;amp;#8595;]]></dc:creator><pubDate>Thu, 13 Oct 2005 21:32:10 GMT</pubDate></item><item><title><![CDATA[Reply to Strings in C-Strings umwandeln on Thu, 13 Oct 2005 21:34:43 GMT]]></title><description><![CDATA[<p>Klar! Aber wofür?</p>
<p>Bye, TGGC (<a href="http://tggc.tg.funpic.de/index.php?cat=4" rel="nofollow">Demo or Die</a>)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/891862</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/891862</guid><dc:creator><![CDATA[TGGC]]></dc:creator><pubDate>Thu, 13 Oct 2005 21:34:43 GMT</pubDate></item><item><title><![CDATA[Reply to Strings in C-Strings umwandeln on Thu, 13 Oct 2005 21:44:11 GMT]]></title><description><![CDATA[<p>damit man nicht das delete[] vergisst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/891870</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/891870</guid><dc:creator><![CDATA[Optimizer&amp;amp;#8595;]]></dc:creator><pubDate>Thu, 13 Oct 2005 21:44:11 GMT</pubDate></item><item><title><![CDATA[Reply to Strings in C-Strings umwandeln on Fri, 14 Oct 2005 06:15:03 GMT]]></title><description><![CDATA[<p>Optimizer↓ schrieb:</p>
<blockquote>
<p>echte männer nehmen std::vector.</p>
</blockquote>
<p>Falsch - echte Männer rechnen direkt auf str.c_str() (oder nutzen gleich die string-eigenen Methoden).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/891962</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/891962</guid><dc:creator><![CDATA[CS]]></dc:creator><pubDate>Fri, 14 Oct 2005 06:15:03 GMT</pubDate></item></channel></rss>