<?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[länge eines string arrays]]></title><description><![CDATA[<p>hi,</p>
<p>ich hab folgendes problem. Ich würde gerne die Länge eines std::string arrays ermitteln. Das geht ja leider nich wie bei anderen arrays mit sizeof(dasArray)/sizeof(typDesArrays).<br />
Ich hab auch ne Lösung gefunden allerdings geht die nur für den debug modus von VC++.</p>
<p>Dafür das mich hier niemand falsch versteht. Ich will nicht die Länge eines std::strings ermitteln sondern eines std::string arrays, also die Anzahl der Elemente... also:<br />
std::string arr[] = {&quot;a&quot;, &quot;b&quot;, &quot;c&quot;};</p>
<p>Danke schonmal für jede hilfe</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/254435/länge-eines-string-arrays</link><generator>RSS for Node</generator><lastBuildDate>Sat, 12 Sep 2026 18:18:02 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/254435.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 16 Nov 2009 16:07:52 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to länge eines string arrays on Mon, 16 Nov 2009 16:07:52 GMT]]></title><description><![CDATA[<p>hi,</p>
<p>ich hab folgendes problem. Ich würde gerne die Länge eines std::string arrays ermitteln. Das geht ja leider nich wie bei anderen arrays mit sizeof(dasArray)/sizeof(typDesArrays).<br />
Ich hab auch ne Lösung gefunden allerdings geht die nur für den debug modus von VC++.</p>
<p>Dafür das mich hier niemand falsch versteht. Ich will nicht die Länge eines std::strings ermitteln sondern eines std::string arrays, also die Anzahl der Elemente... also:<br />
std::string arr[] = {&quot;a&quot;, &quot;b&quot;, &quot;c&quot;};</p>
<p>Danke schonmal für jede hilfe</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1808884</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1808884</guid><dc:creator><![CDATA[1700]]></dc:creator><pubDate>Mon, 16 Nov 2009 16:07:52 GMT</pubDate></item><item><title><![CDATA[Reply to länge eines string arrays on Mon, 16 Nov 2009 16:21:57 GMT]]></title><description><![CDATA[<p>Das sollte eigentlich mit sizeof(dasArray)/sizeof(typDesArrays) gehen, was funktioniert denn nicht?</p>
<p>edit: Hier noch eine Demo:</p>
<pre><code class="language-cpp">#include &lt;string&gt;
#include &lt;iostream&gt;
int main()
{
std::string arr[] = {
   &quot;Der Speicherplatz für den Inhalt des Strings liegt auf dem Heap&quot;, 
   &quot;Der String selbst ist bloß ein Struct mit ein paar Verwaltungsdaten und einem Pointer&quot;, 
   &quot;Stringarrays verhalten sich daher wie alle anderen Arrays auch, egal wie lang die Zeichenketten sind&quot;}; 

std::cout&lt;&lt;sizeof(arr)/sizeof(std::string)&lt;&lt;std::endl; // 3

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1808893</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1808893</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Mon, 16 Nov 2009 16:21:57 GMT</pubDate></item><item><title><![CDATA[Reply to länge eines string arrays on Mon, 16 Nov 2009 16:16:40 GMT]]></title><description><![CDATA[<p>1700 schrieb:</p>
<blockquote>
<p>Dafür das mich hier niemand falsch versteht. Ich will nicht die Länge eines std::strings ermitteln sondern eines std::string arrays, also die Anzahl der Elemente... also:<br />
std::string arr[] = {&quot;a&quot;, &quot;b&quot;, &quot;c&quot;};</p>
<p>Das geht ja leider nich wie bei anderen arrays mit sizeof(dasArray)/sizeof(typDesArrays).</p>
</blockquote>
<p>Müsste aber.<br />
<code>sizeof(arr)/sizeof(arr[0])</code></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1808895</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1808895</guid><dc:creator><![CDATA[Sebastian Pizer]]></dc:creator><pubDate>Mon, 16 Nov 2009 16:16:40 GMT</pubDate></item><item><title><![CDATA[Reply to länge eines string arrays on Mon, 16 Nov 2009 16:23:24 GMT]]></title><description><![CDATA[<p>hä ok... jetzt klappt es irgendwie echt.... sorry dann muss ich irgendwas falsch gemacht haben:D</p>
<p>alles klar danke thread kann geschlossen werden :D:D</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1808899</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1808899</guid><dc:creator><![CDATA[1700]]></dc:creator><pubDate>Mon, 16 Nov 2009 16:23:24 GMT</pubDate></item><item><title><![CDATA[Reply to länge eines string arrays on Mon, 16 Nov 2009 16:29:55 GMT]]></title><description><![CDATA[<p>1700 schrieb:</p>
<blockquote>
<p>alles klar danke thread kann geschlossen werden :D:D</p>
</blockquote>
<p>Nicht so schnell: Wenn du Arrays unbekannter Größe hast, bist du sicher, dass Arrays die optimale Datenstruktur für dein Problem sind? Vielleicht wäre sowas wie std::vector oder eine gekapselte Arrayklasse besser.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1808905</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1808905</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Mon, 16 Nov 2009 16:29:55 GMT</pubDate></item><item><title><![CDATA[Reply to länge eines string arrays on Mon, 16 Nov 2009 17:49:22 GMT]]></title><description><![CDATA[<p>nene das is n vordefiniertes array... für dynamische zwecke nutze ich std::vector <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/1808947</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1808947</guid><dc:creator><![CDATA[1700]]></dc:creator><pubDate>Mon, 16 Nov 2009 17:49:22 GMT</pubDate></item><item><title><![CDATA[Reply to länge eines string arrays on Mon, 16 Nov 2009 22:33:11 GMT]]></title><description><![CDATA[<p>1700 schrieb:</p>
<blockquote>
<p>nene das is n vordefiniertes array... für dynamische zwecke nutze ich std::vector <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>
</blockquote>
<p>Und für statische empfehle ich dir, <code>std::tr1::array</code> zu nutzen (oder <code>boost::array</code> ). Das hat keinen Overhead gegenüber BuiltIn-Arrays, aber besitzt Laufzeitprüfungen im Debug-Modus und ein STL-kompatibles Interface (z.B. <code>size()</code> -Methode), was beides von grossem Vorteil sein kann.</p>
<p>Ich verwende kaum noch rohe Arrays und war schon mehrere Male um die Assertions von <code>std::tr1::array</code> froh, welche schwer auffindbare Fehler vermieden hatten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1809092</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1809092</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Mon, 16 Nov 2009 22:33:11 GMT</pubDate></item></channel></rss>