<?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[char* verbinden mit char*]]></title><description><![CDATA[<p>Hallo, wie kann ich 2 variablen vom typ char* verbinden? -&gt; Garnich! ?!?<br />
wie würdet ihr folgendes problem lösen:</p>
<pre><code class="language-cpp">xyzfunktion(char* Datei)
</code></pre>
<p>Mit string währe es ja kein problem... aber die funktion erwartet eben char*</p>
<p>z.B.</p>
<pre><code class="language-cpp">char *path = &quot;c:\\blub&quot;;
char *datei = &quot;huhu.txt&quot;;
xyzfunktion(path+&quot;\\&quot;+datei); // geht natürlich nicht. aber wie macht man sowas?
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/67658/char-verbinden-mit-char</link><generator>RSS for Node</generator><lastBuildDate>Thu, 09 Jul 2026 20:21:47 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/67658.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 10 Mar 2004 12:50:41 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to char* verbinden mit char* on Wed, 10 Mar 2004 12:51:26 GMT]]></title><description><![CDATA[<p>Hallo, wie kann ich 2 variablen vom typ char* verbinden? -&gt; Garnich! ?!?<br />
wie würdet ihr folgendes problem lösen:</p>
<pre><code class="language-cpp">xyzfunktion(char* Datei)
</code></pre>
<p>Mit string währe es ja kein problem... aber die funktion erwartet eben char*</p>
<p>z.B.</p>
<pre><code class="language-cpp">char *path = &quot;c:\\blub&quot;;
char *datei = &quot;huhu.txt&quot;;
xyzfunktion(path+&quot;\\&quot;+datei); // geht natürlich nicht. aber wie macht man sowas?
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/477334</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/477334</guid><dc:creator><![CDATA[MeisterMichi]]></dc:creator><pubDate>Wed, 10 Mar 2004 12:51:26 GMT</pubDate></item><item><title><![CDATA[Reply to char* verbinden mit char* on Wed, 10 Mar 2004 12:54:16 GMT]]></title><description><![CDATA[<p>std::strcat()</p>
]]></description><link>https://www.c-plusplus.net/forum/post/477340</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/477340</guid><dc:creator><![CDATA[der_Held]]></dc:creator><pubDate>Wed, 10 Mar 2004 12:54:16 GMT</pubDate></item><item><title><![CDATA[Reply to char* verbinden mit char* on Wed, 10 Mar 2004 12:56:41 GMT]]></title><description><![CDATA[<blockquote>
<pre><code>char *path = &quot;c:\\blub&quot;;
char *datei = &quot;huhu.txt&quot;;
xyzfunktion(path+&quot;\\&quot;+datei); // geht natürlich nicht. aber wie macht man sowas?
</code></pre>
</blockquote>
<pre><code class="language-cpp">char *filename = new char[strlen(path) + 1 + strlen(datei) + 1];
strcpy(filename, path);
strcat(filename, &quot;\\&quot;);
strcat(filename, datei);
xyzfunktion(filename);
delete[] filename;
</code></pre>
<p>Das ist noch nicht maximal performant, aber es funktioniert und reicht für deinen Zweck. Als Übung kannst du noch den «Schlehmil» entfernen <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/477344</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/477344</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Wed, 10 Mar 2004 12:56:41 GMT</pubDate></item><item><title><![CDATA[Reply to char* verbinden mit char* on Wed, 10 Mar 2004 13:08:44 GMT]]></title><description><![CDATA[<p>MeisterMichi schrieb:</p>
<blockquote>
<p>Mit string währe es ja kein problem... aber die funktion erwartet eben char*</p>
</blockquote>
<p>und, warum dann keinen std::string nehmen?</p>
<pre><code class="language-cpp">string str1 = &quot;c:\\blub&quot;;
string str2 = &quot;\\&quot;;
string str3 = &quot;huhu.txt&quot;;
string str4 = str1 + str2 + str3;

xyzfunktion(str4.c_str());
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/477354</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/477354</guid><dc:creator><![CDATA[Jover]]></dc:creator><pubDate>Wed, 10 Mar 2004 13:08:44 GMT</pubDate></item><item><title><![CDATA[Reply to char* verbinden mit char* on Wed, 10 Mar 2004 13:10:06 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">xyzfunktion(path+&quot;\\&quot;+datei); // geht natürlich nicht. aber wie macht man sowas?
</code></pre>
<pre><code class="language-cpp">xyzfunktion(string(path)+&quot;\\&quot;+datei); // geht natürlich. denn so macht man sowas!
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/477357</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/477357</guid><dc:creator><![CDATA[der_Held]]></dc:creator><pubDate>Wed, 10 Mar 2004 13:10:06 GMT</pubDate></item><item><title><![CDATA[Reply to char* verbinden mit char* on Wed, 10 Mar 2004 13:22:02 GMT]]></title><description><![CDATA[<p>hay, das sind ja gleich 4 antworten auf einmal <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /><br />
danke euch<br />
damit kann ich arbeiten</p>
]]></description><link>https://www.c-plusplus.net/forum/post/477372</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/477372</guid><dc:creator><![CDATA[MeisterMichi]]></dc:creator><pubDate>Wed, 10 Mar 2004 13:22:02 GMT</pubDate></item><item><title><![CDATA[Reply to char* verbinden mit char* on Wed, 10 Mar 2004 13:29:19 GMT]]></title><description><![CDATA[<p>Ich würde dir allerdings strncpy/strncat empfehlen, da es sicherer ist. Oder noch besser: snprintf.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/477383</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/477383</guid><dc:creator><![CDATA[CarstenJ]]></dc:creator><pubDate>Wed, 10 Mar 2004 13:29:19 GMT</pubDate></item><item><title><![CDATA[Reply to char* verbinden mit char* on Wed, 10 Mar 2004 13:33:52 GMT]]></title><description><![CDATA[<p>Oh, Fehler in meiner Antwort:</p>
<pre><code class="language-cpp">xyzfunktion((string(path)+&quot;\\&quot;+datei).c_str()); // geht natürlich. denn so macht man sowas!
</code></pre>
<p>und das ist mindestens genauso sicher, wie strncpy und Konsorten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/477391</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/477391</guid><dc:creator><![CDATA[der_Held]]></dc:creator><pubDate>Wed, 10 Mar 2004 13:33:52 GMT</pubDate></item><item><title><![CDATA[Reply to char* verbinden mit char* on Wed, 10 Mar 2004 14:16:22 GMT]]></title><description><![CDATA[<p>Ja, das würde ich sogar vorziehen. Aber ich weiss ja nicht, ob er string überhaupt benutzen darf. Außerdem meinte ich auch eher strncpy/strncat statt strcpy/strcat.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/477438</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/477438</guid><dc:creator><![CDATA[CarstenJ]]></dc:creator><pubDate>Wed, 10 Mar 2004 14:16:22 GMT</pubDate></item><item><title><![CDATA[Reply to char* verbinden mit char* on Wed, 10 Mar 2004 14:28:15 GMT]]></title><description><![CDATA[<p>Dass die n-Funktionen sicherer sind ist auch nur ein Allgemeinplatz.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/477455</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/477455</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Wed, 10 Mar 2004 14:28:15 GMT</pubDate></item><item><title><![CDATA[Reply to char* verbinden mit char* on Wed, 10 Mar 2004 14:33:29 GMT]]></title><description><![CDATA[<p>CarstenJ schrieb:</p>
<blockquote>
<p>Ja, das würde ich sogar vorziehen. Aber ich weiss ja nicht, ob er string überhaupt benutzen darf.</p>
</blockquote>
<p>Warum soll er string nicht benutzen dürfen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/477462</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/477462</guid><dc:creator><![CDATA[Jover]]></dc:creator><pubDate>Wed, 10 Mar 2004 14:33:29 GMT</pubDate></item><item><title><![CDATA[Reply to char* verbinden mit char* on Wed, 10 Mar 2004 14:43:02 GMT]]></title><description><![CDATA[<p>Bashar schrieb:</p>
<blockquote>
<p>Dass die n-Funktionen sicherer sind ist auch nur ein Allgemeinplatz.</p>
</blockquote>
<p>Hä?</p>
<p>Jover schrieb:</p>
<blockquote>
<p>Warum soll er string nicht benutzen dürfen?</p>
</blockquote>
<p>Woher soll ich das wissen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/477472</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/477472</guid><dc:creator><![CDATA[CarstenJ]]></dc:creator><pubDate>Wed, 10 Mar 2004 14:43:02 GMT</pubDate></item><item><title><![CDATA[Reply to char* verbinden mit char* on Wed, 10 Mar 2004 16:47:59 GMT]]></title><description><![CDATA[<p>CarstenJ schrieb:</p>
<blockquote>
<p>Bashar schrieb:</p>
<blockquote>
<p>Dass die n-Funktionen sicherer sind ist auch nur ein Allgemeinplatz.</p>
</blockquote>
<p>Hä?</p>
</blockquote>
<p>Die n Varianten können Sinnvoll sein - aber um ehrlich zu sein, ich habe sie fast nie verwendet. Weil ich einfach immer weiss wie groß meine strings sind - und wenn nicht, kann ich mit strlen() nachsehen <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/477671</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/477671</guid><dc:creator><![CDATA[Shade Of Mine]]></dc:creator><pubDate>Wed, 10 Mar 2004 16:47:59 GMT</pubDate></item><item><title><![CDATA[Reply to char* verbinden mit char* on Wed, 10 Mar 2004 16:54:17 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">Ich würde dir allerdings strncpy/strncat empfehlen, da es sicherer ist. Oder noch besser: snprintf.
</code></pre>
<p>Seit Wann ist eine C-Funktion sicherer als eine string-Methode?</p>
<p>MfG MAV</p>
]]></description><link>https://www.c-plusplus.net/forum/post/477675</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/477675</guid><dc:creator><![CDATA[Mis2com]]></dc:creator><pubDate>Wed, 10 Mar 2004 16:54:17 GMT</pubDate></item><item><title><![CDATA[Reply to char* verbinden mit char* on Wed, 10 Mar 2004 17:18:33 GMT]]></title><description><![CDATA[<blockquote>
<p>Seit Wann ist eine C-Funktion sicherer als eine string-Methode?</p>
</blockquote>
<p>Lol..ist ja mal wieder nen geiler Thread. Ich würde dir empfehlen, vorher mal alles zu lesen und zu verarbeiten, statt einfach Irgendwas zu posten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/477710</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/477710</guid><dc:creator><![CDATA[CarstenJ]]></dc:creator><pubDate>Wed, 10 Mar 2004 17:18:33 GMT</pubDate></item><item><title><![CDATA[Reply to char* verbinden mit char* on Wed, 10 Mar 2004 17:54:29 GMT]]></title><description><![CDATA[<p>CarstenJ schrieb:</p>
<blockquote>
<p>Hä?</p>
</blockquote>
<p>Nur so dahergesagt, weil es im Allgemeinen mit den herkömmlichen Funktionen mehr Sicherheitsprobleme gibt. Das heißt ja nicht, dass man automatisch sicherer wird, wenn man die n-Funktionen verwendet. Schon gar nicht hier in diesem Beispiel.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/477768</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/477768</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Wed, 10 Mar 2004 17:54:29 GMT</pubDate></item></channel></rss>