<?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[sizeof(string)]]></title><description><![CDATA[<p>Ich bin grad auf etwas gestossen, das mir nicht ganz klar ist.<br />
Wieso ist sizeoh(string) konstant? Bei mir 4.<br />
Ich meine die Groesse von einem String bestimmen doch die Anzahl der Buchstaben, wie kann das dann konstant sein.<br />
Mir ist klar, dass ein int, bool, char, double und was weiss ich noch alles konstant sein muss.<br />
Haben dann auch container ne konstante Groesse? Mir ist das grad alles ziemlich unklar.<br />
Wär froh wenn mir das alles jemand erklären könnte.</p>
<p>MFG<br />
chewbo</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/162532/sizeof-string</link><generator>RSS for Node</generator><lastBuildDate>Sat, 12 Sep 2026 09:20:08 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/162532.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 19 Oct 2006 14:37:03 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to sizeof(string) on Thu, 19 Oct 2006 14:37:03 GMT]]></title><description><![CDATA[<p>Ich bin grad auf etwas gestossen, das mir nicht ganz klar ist.<br />
Wieso ist sizeoh(string) konstant? Bei mir 4.<br />
Ich meine die Groesse von einem String bestimmen doch die Anzahl der Buchstaben, wie kann das dann konstant sein.<br />
Mir ist klar, dass ein int, bool, char, double und was weiss ich noch alles konstant sein muss.<br />
Haben dann auch container ne konstante Groesse? Mir ist das grad alles ziemlich unklar.<br />
Wär froh wenn mir das alles jemand erklären könnte.</p>
<p>MFG<br />
chewbo</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1157698</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1157698</guid><dc:creator><![CDATA[chewbo]]></dc:creator><pubDate>Thu, 19 Oct 2006 14:37:03 GMT</pubDate></item><item><title><![CDATA[Reply to sizeof(string) on Thu, 19 Oct 2006 14:42:19 GMT]]></title><description><![CDATA[<p>Für die Länge des string nehm die member funktion size().</p>
<pre><code class="language-cpp">std::string xd = &quot;asdasdasd&quot;;
std::cout &lt;&lt; xd.size();
</code></pre>
<p>mfg.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1157703</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1157703</guid><dc:creator><![CDATA[joomoo]]></dc:creator><pubDate>Thu, 19 Oct 2006 14:42:19 GMT</pubDate></item><item><title><![CDATA[Reply to sizeof(string) on Thu, 19 Oct 2006 14:43:03 GMT]]></title><description><![CDATA[<p>Das wollte ich eben auch posten. Das war aber nicht die Frage.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1157705</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1157705</guid><dc:creator><![CDATA[Apollon]]></dc:creator><pubDate>Thu, 19 Oct 2006 14:43:03 GMT</pubDate></item><item><title><![CDATA[Reply to sizeof(string) on Thu, 19 Oct 2006 14:44:22 GMT]]></title><description><![CDATA[<p>sollte aber als antwort genügen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1157707</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1157707</guid><dc:creator><![CDATA[joomoo]]></dc:creator><pubDate>Thu, 19 Oct 2006 14:44:22 GMT</pubDate></item><item><title><![CDATA[Reply to sizeof(string) on Thu, 19 Oct 2006 14:48:46 GMT]]></title><description><![CDATA[<p>Hmm das war wirklich nicht das was ich meinte. Um genau zu sein hab ich hier ein stueck Kot das ich zwar verstehe aber halt nicht warum.</p>
<pre><code>string words[]={ string(&quot;....&quot;),string(&quot;....&quot;),...};
const int n_words = sizeof words / sizeof(string);
</code></pre>
<p>Ich kriege die richtige Anzahl von Worter raus aber wie gesagt warum hat jeder String die Groesse von 4?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1157711</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1157711</guid><dc:creator><![CDATA[chewbo]]></dc:creator><pubDate>Thu, 19 Oct 2006 14:48:46 GMT</pubDate></item><item><title><![CDATA[Reply to sizeof(string) on Thu, 19 Oct 2006 14:53:14 GMT]]></title><description><![CDATA[<p>vermutlich weil Deine Stringimplementierung intern nur einen char* - Pointer als member hat und der ist 4 Byte groß.</p>
<blockquote>
<p>const int n_words = sizeof words / sizeof(string);</p>
</blockquote>
<p>ist eigentlich eine gängige Variante um zu bestimmen, wie viele Elemente in einem &quot;normalen&quot; Array sind - unabhängig davon, warum sizeof(string) nun 4 ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1157717</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1157717</guid><dc:creator><![CDATA[TheBigW]]></dc:creator><pubDate>Thu, 19 Oct 2006 14:53:14 GMT</pubDate></item><item><title><![CDATA[Reply to sizeof(string) on Thu, 19 Oct 2006 14:55:42 GMT]]></title><description><![CDATA[<p>Das macht Sinn. danke. wieder ein bisschen wissender geworden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1157723</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1157723</guid><dc:creator><![CDATA[chewbo]]></dc:creator><pubDate>Thu, 19 Oct 2006 14:55:42 GMT</pubDate></item><item><title><![CDATA[Reply to sizeof(string) on Thu, 19 Oct 2006 14:58:44 GMT]]></title><description><![CDATA[<p>chewbo schrieb:</p>
<blockquote>
<p>...warum hat jeder String die Groesse von 4?</p>
</blockquote>
<p>Ist Dir klar, was sizeof bei Klassen macht ?<br />
Beispiel:</p>
<pre><code class="language-cpp">struct S {
    char* s;
    int l;
};

int main() {
    std::cout &lt;&lt; sizeof(S);
    return 0;
}
</code></pre>
<p>Klar, was das macht ?<br />
Und das ist eine &quot;Simpelvariante von std::string&quot;....</p>
<p>Gruß,</p>
<p>Simon2.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1157726</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1157726</guid><dc:creator><![CDATA[Simon2]]></dc:creator><pubDate>Thu, 19 Oct 2006 14:58:44 GMT</pubDate></item><item><title><![CDATA[Reply to sizeof(string) on Thu, 19 Oct 2006 16:47:18 GMT]]></title><description><![CDATA[<p>Nö, es ist ihm nicht Klar was sizeof() macht, das ist ja das Erschreckende.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1157832</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1157832</guid><dc:creator><![CDATA[Plotzenhotz]]></dc:creator><pubDate>Thu, 19 Oct 2006 16:47:18 GMT</pubDate></item></channel></rss>