<?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++]]></title><description><![CDATA[<p><strong>Wie ist das wenn man mehrer Variablen in einem String zusammenfügen möchte?</strong><br />
Beispiel:</p>
<pre><code class="language-cpp">while ((row = mysql_fetch_row (res)) != NULL)
{
anzeige=row[0];
anzeige=anzeige + (&quot;, &quot;) + row[1];
n++;
TextOut(hDC, 3, ((n)*20)+20, anzeige.c_str(), sizeof(anzeige));
}
</code></pre>
<p>Das klappt so (mit einem Fehler, den ich gleich noch nennen möchte), aber wieso kann ich nicht schreiben<br />
anzeige=row[0]+(&quot;, &quot;)+row[1];<br />
Dann sagt er mir nämlich immer, dass zwei Zeiger nicht addiert werden können.</p>
<p>Kann man das auch mit char lösen?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/125838/strings-in-c</link><generator>RSS for Node</generator><lastBuildDate>Mon, 24 Aug 2026 10:38:46 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/125838.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 09 Nov 2005 20:23:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Strings in C++ on Wed, 09 Nov 2005 20:35:20 GMT]]></title><description><![CDATA[<p><strong>Wie ist das wenn man mehrer Variablen in einem String zusammenfügen möchte?</strong><br />
Beispiel:</p>
<pre><code class="language-cpp">while ((row = mysql_fetch_row (res)) != NULL)
{
anzeige=row[0];
anzeige=anzeige + (&quot;, &quot;) + row[1];
n++;
TextOut(hDC, 3, ((n)*20)+20, anzeige.c_str(), sizeof(anzeige));
}
</code></pre>
<p>Das klappt so (mit einem Fehler, den ich gleich noch nennen möchte), aber wieso kann ich nicht schreiben<br />
anzeige=row[0]+(&quot;, &quot;)+row[1];<br />
Dann sagt er mir nämlich immer, dass zwei Zeiger nicht addiert werden können.</p>
<p>Kann man das auch mit char lösen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/913286</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/913286</guid><dc:creator><![CDATA[lomtas]]></dc:creator><pubDate>Wed, 09 Nov 2005 20:35:20 GMT</pubDate></item><item><title><![CDATA[Reply to Strings in C++ on Wed, 09 Nov 2005 20:38:24 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>lomtas schrieb:</p>
<blockquote>
<p>aber wieso kann ich nicht schreiben</p>
</blockquote>
<p>...weil...</p>
<blockquote>
<p>...zwei Zeiger nicht addiert werden können.</p>
</blockquote>
<p>Ein char[] wird als char* repräsentiert wenn du es an eine Funktion übergibst.<br />
Wenn du die richtige Größe des Arrays haben möchtest, musst du das so berechnen:</p>
<pre><code class="language-cpp">int len = sizeof(anzeige)/sizeof(char);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/913302</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/913302</guid><dc:creator><![CDATA[CarstenJ]]></dc:creator><pubDate>Wed, 09 Nov 2005 20:38:24 GMT</pubDate></item><item><title><![CDATA[Reply to Strings in C++ on Wed, 09 Nov 2005 20:51:56 GMT]]></title><description><![CDATA[<p>Kann ich die dann irgendwie nicht als Zeiger, sondern direkt als variablen übergeben?</p>
<p>Weil ich komme halt von PHP und da waren solche Dinge klein Problem:<br />
select=&quot;SELECT name, vorname FROM k_kontakt WHERE date_formate(geburtstag,%m)='&quot; + st.wMonth + &quot;' LIMIT 0,1&quot;;<br />
Wie kann ich das in c++ relasieren (er meckert da nämlich schon wieder von wegen zwei zeigern....)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/913331</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/913331</guid><dc:creator><![CDATA[lomtas]]></dc:creator><pubDate>Wed, 09 Nov 2005 20:51:56 GMT</pubDate></item><item><title><![CDATA[Reply to Strings in C++ on Wed, 09 Nov 2005 21:00:11 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>moment, ich hab mich vertan:</p>
<pre><code class="language-cpp">sizeof(anzeige)
</code></pre>
<p>Ist natürlich auch richtig, weil ein char sowieso immer die Größe 1 hat.</p>
<p>EDIT:<br />
Ok, jetzt verstehe ich. Du kannst strings addieren, wenn es sich um den Typ std::string handelt:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
using namespace std;

int main()
{
    string anzeige = &quot;hallo&quot; ;
    char    row[]=&quot;welt&quot;;
    anzeige = anzeige + &quot;, &quot; + row;

    cout &lt;&lt; anzeige &lt;&lt; endl;
}
</code></pre>
<p>Das geht mit char* nicht so einfach, da müsstest du dir mal die Funktion strcpy etc. ansehen:<br />
<a href="http://man.cx/strcpy" rel="nofollow">man: strcpy</a></p>
<p>Std::string machte einem das schon sehr viel leichter.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/913338</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/913338</guid><dc:creator><![CDATA[CarstenJ]]></dc:creator><pubDate>Wed, 09 Nov 2005 21:00:11 GMT</pubDate></item><item><title><![CDATA[Reply to Strings in C++ on Wed, 09 Nov 2005 20:54:22 GMT]]></title><description><![CDATA[<p>habe mein beitrag über deinem noch mal editiert. ist das verständlich?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/913340</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/913340</guid><dc:creator><![CDATA[lomtas]]></dc:creator><pubDate>Wed, 09 Nov 2005 20:54:22 GMT</pubDate></item><item><title><![CDATA[Reply to Strings in C++ on Wed, 09 Nov 2005 21:04:06 GMT]]></title><description><![CDATA[<p>Ich verstehe erstens nicht, was CarstenJs Posts sagen soll.</p>
<p>Und zweitens ehrlichgesagt nicht, warum das nicht funktioniert.</p>
<p>anzeige ist ja anscheinend ein std::string (schließe ich aus dem .c_str()). string + const char * gibt string. Und dazu kann man nochmal const char * addieren. Das mit dem sizeof ist natürlich Unsinn, das sollte wohl anzeige.length() heißen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/913354</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/913354</guid><dc:creator><![CDATA[Ringding]]></dc:creator><pubDate>Wed, 09 Nov 2005 21:04:06 GMT</pubDate></item><item><title><![CDATA[Reply to Strings in C++ on Wed, 09 Nov 2005 21:06:55 GMT]]></title><description><![CDATA[<blockquote>
<p>Ich verstehe erstens nicht, was CarstenJs Posts sagen soll.</p>
</blockquote>
<p>Ich auch nicht mehr. Hab die Hälfte überlesen. <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/913357</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/913357</guid><dc:creator><![CDATA[CarstenJ]]></dc:creator><pubDate>Wed, 09 Nov 2005 21:06:55 GMT</pubDate></item><item><title><![CDATA[Reply to Strings in C++ on Thu, 10 Nov 2005 07:15:56 GMT]]></title><description><![CDATA[<p>CarstenJ schrieb:</p>
<blockquote>
<p>Hallo,</p>
<p>moment, ich hab mich vertan:</p>
<pre><code class="language-cpp">sizeof(anzeige)
</code></pre>
<p>Ist natürlich auch richtig, weil ein char sowieso immer die Größe 1 hat.</p>
</blockquote>
<p>&quot;sizeof(anzeige)&quot; ist nicht richtig, wenn du die Länge der Zeichenkette ermittlen willst - dafür benötigst du bei C++ Strings &quot;anzeige.size()&quot;. (mit dem sizeof-Operator erhältst du nur die Größe der String-Struktur - und die ist konstant)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/913548</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/913548</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Thu, 10 Nov 2005 07:15:56 GMT</pubDate></item><item><title><![CDATA[Reply to Strings in C++ on Thu, 10 Nov 2005 09:00:22 GMT]]></title><description><![CDATA[<p>War doch schon geklärt soweit ich richtig gelesen habe....</p>
]]></description><link>https://www.c-plusplus.net/forum/post/913642</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/913642</guid><dc:creator><![CDATA[cj@work]]></dc:creator><pubDate>Thu, 10 Nov 2005 09:00:22 GMT</pubDate></item><item><title><![CDATA[Reply to Strings in C++ on Thu, 10 Nov 2005 11:53:59 GMT]]></title><description><![CDATA[<p>anzeige.size oder anzeige.lenght?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/913791</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/913791</guid><dc:creator><![CDATA[lomtas]]></dc:creator><pubDate>Thu, 10 Nov 2005 11:53:59 GMT</pubDate></item><item><title><![CDATA[Reply to Strings in C++ on Thu, 10 Nov 2005 12:03:10 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p><a href="http://www.cppreference.com/cppstring/length.html" rel="nofollow">http://www.cppreference.com/cppstring/length.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/913798</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/913798</guid><dc:creator><![CDATA[cj@work]]></dc:creator><pubDate>Thu, 10 Nov 2005 12:03:10 GMT</pubDate></item></channel></rss>