<?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[Woher weiß der Compiler wie &amp;quot;Breit&amp;quot; das Array ist?]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;iostream&gt;
using namespace std;

void foo(char** bar)
{
	for (int y = 0; y &lt; 10; y++)
	{
		for (int x = 0; x &lt; 10; x++)
		{
			// woher weiß der Compiler wie &quot;Breit&quot; das Array ist?
			bar[x][y] = x+y*10;	

		}
	}
}

int main()
{
	char **array = new char*[10];

	for(int i = 0; i &lt; 10; i++)
	{
		array[i] = new char[10];
	}

	foo(array);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/196959/woher-weiß-der-compiler-wie-quot-breit-quot-das-array-ist</link><generator>RSS for Node</generator><lastBuildDate>Wed, 30 Sep 2026 22:26:21 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/196959.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 04 Nov 2007 23:23:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Woher weiß der Compiler wie &amp;quot;Breit&amp;quot; das Array ist? on Sun, 04 Nov 2007 23:23:34 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;iostream&gt;
using namespace std;

void foo(char** bar)
{
	for (int y = 0; y &lt; 10; y++)
	{
		for (int x = 0; x &lt; 10; x++)
		{
			// woher weiß der Compiler wie &quot;Breit&quot; das Array ist?
			bar[x][y] = x+y*10;	

		}
	}
}

int main()
{
	char **array = new char*[10];

	for(int i = 0; i &lt; 10; i++)
	{
		array[i] = new char[10];
	}

	foo(array);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1397809</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1397809</guid><dc:creator><![CDATA[Vertexwahn]]></dc:creator><pubDate>Sun, 04 Nov 2007 23:23:34 GMT</pubDate></item><item><title><![CDATA[Reply to Woher weiß der Compiler wie &amp;quot;Breit&amp;quot; das Array ist? on Mon, 05 Nov 2007 00:16:13 GMT]]></title><description><![CDATA[<p>Das weiß der Compiler gar nicht! Wenn du eine Speicherstelle außerhalb des Arrays mit den Indizes ansprichst, dann gibts einen sogennanten Segmention fault <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="🙂"
    /><br />
Um so etwas vorzubeugen ist der Programmierer da. Hifreich könnte in diesem Fall std::vector sein, da die at() Methode eine Bereichsprüfung vornimmt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1397818</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1397818</guid><dc:creator><![CDATA[ich_du_er]]></dc:creator><pubDate>Mon, 05 Nov 2007 00:16:13 GMT</pubDate></item><item><title><![CDATA[Reply to Woher weiß der Compiler wie &amp;quot;Breit&amp;quot; das Array ist? on Mon, 05 Nov 2007 01:45:14 GMT]]></title><description><![CDATA[<p>Wie schon gesagt kann er es garnicht. Du musst entweder die Dimensionen mit übergeben, oder char (*bar)[10], char bar[10][10], char bar[][10] bzw. gleich vector&lt; vector&lt;char&gt; &gt; benutzen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1397820</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1397820</guid><dc:creator><![CDATA[this-*gt*that]]></dc:creator><pubDate>Mon, 05 Nov 2007 01:45:14 GMT</pubDate></item><item><title><![CDATA[Reply to Woher weiß der Compiler wie &amp;quot;Breit&amp;quot; das Array ist? on Mon, 05 Nov 2007 07:05:14 GMT]]></title><description><![CDATA[<p>Falls die Frage damit noch nicht beantwortet ist: Er muss es nicht wissen, weil du kein zweidimensionales Array vorliegen hast.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1397843</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1397843</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Mon, 05 Nov 2007 07:05:14 GMT</pubDate></item></channel></rss>