<?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[Zugriffsverletzung]]></title><description><![CDATA[<p>Hallo,</p>
<p>Ich habe eine eigenartige Zugriffsverletzung (sowohl bei VC 2003, als auch bei g++) bei folgende code:</p>
<pre><code>char buf[1000*sizeof(char)];
sprintf(buf,&quot;http://de.altavista.com/web/results?itag=wrx&amp;q=blumen&amp;kgs=1&amp;kls=0&amp;stq=0&quot;);
</code></pre>
<p>-&gt; Zugriffsverletzung &quot;visualstudio/crt/src/output.c&quot; (zeile 1135)</p>
<p>Wenn ich jetzt aber z.b. &quot;blumen&quot; durch &quot;bluen&quot; oder &quot;xblumen&quot; ersetze, dann tritt der fehler plötzlich nicht mehr auf. gleicher passiert auch bei manchen anderen wörtern.</p>
<p>Woran kann das liegen?</p>
<p>grüße,</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/119628/zugriffsverletzung</link><generator>RSS for Node</generator><lastBuildDate>Sat, 22 Aug 2026 03:21:35 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/119628.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 03 Sep 2005 12:38:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Zugriffsverletzung on Sat, 03 Sep 2005 12:38:10 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Ich habe eine eigenartige Zugriffsverletzung (sowohl bei VC 2003, als auch bei g++) bei folgende code:</p>
<pre><code>char buf[1000*sizeof(char)];
sprintf(buf,&quot;http://de.altavista.com/web/results?itag=wrx&amp;q=blumen&amp;kgs=1&amp;kls=0&amp;stq=0&quot;);
</code></pre>
<p>-&gt; Zugriffsverletzung &quot;visualstudio/crt/src/output.c&quot; (zeile 1135)</p>
<p>Wenn ich jetzt aber z.b. &quot;blumen&quot; durch &quot;bluen&quot; oder &quot;xblumen&quot; ersetze, dann tritt der fehler plötzlich nicht mehr auf. gleicher passiert auch bei manchen anderen wörtern.</p>
<p>Woran kann das liegen?</p>
<p>grüße,</p>
]]></description><link>https://www.c-plusplus.net/forum/post/864210</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/864210</guid><dc:creator><![CDATA[pixsta]]></dc:creator><pubDate>Sat, 03 Sep 2005 12:38:10 GMT</pubDate></item><item><title><![CDATA[Reply to Zugriffsverletzung on Sat, 03 Sep 2005 12:51:38 GMT]]></title><description><![CDATA[<p>sprint<strong>f</strong>() übernimmt im zweiten Parameter einen Format-String und ab dem dritten die Parameter dafür. Wenn du einfach einen String in einen anderen kopieren willst benütz strcpy:</p>
<pre><code class="language-cpp">strcpy(buf,&quot;...&quot;);
</code></pre>
<p>MfG SideWinder</p>
]]></description><link>https://www.c-plusplus.net/forum/post/864219</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/864219</guid><dc:creator><![CDATA[SideWinder]]></dc:creator><pubDate>Sat, 03 Sep 2005 12:51:38 GMT</pubDate></item><item><title><![CDATA[Reply to Zugriffsverletzung on Sun, 04 Sep 2005 09:56:51 GMT]]></title><description><![CDATA[<p>Darf man mal fragen, wieso du sizeof bei der Deklaration von buf ins Spiel bringst?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/864488</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/864488</guid><dc:creator><![CDATA[groovemaster]]></dc:creator><pubDate>Sun, 04 Sep 2005 09:56:51 GMT</pubDate></item><item><title><![CDATA[Reply to Zugriffsverletzung on Mon, 05 Sep 2005 05:29:26 GMT]]></title><description><![CDATA[<p>wirkt stylischer <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="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/865048</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/865048</guid><dc:creator><![CDATA[Vorden]]></dc:creator><pubDate>Mon, 05 Sep 2005 05:29:26 GMT</pubDate></item><item><title><![CDATA[Reply to Zugriffsverletzung on Mon, 05 Sep 2005 12:18:18 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/10401">@Vorden</a>: Ist aber falsch. In seinem Fall machts keinen Unterschied, weil sizeof(char)==1. Aber stell dir folgendes Szenario vor:</p>
<pre><code class="language-cpp">int buf [1000*sizeof(int)];
</code></pre>
<p>Allokiert 4 Mal soviele ints wie gedacht.</p>
<p>MfG SideWinder</p>
]]></description><link>https://www.c-plusplus.net/forum/post/865370</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/865370</guid><dc:creator><![CDATA[SideWinder]]></dc:creator><pubDate>Mon, 05 Sep 2005 12:18:18 GMT</pubDate></item><item><title><![CDATA[Reply to Zugriffsverletzung on Mon, 05 Sep 2005 12:25:01 GMT]]></title><description><![CDATA[<p>Ja, is klar, aba irgendwie kommt des in Bezug auf char cooler rüber <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="😃"
    /></p>
<p>Könntest ja immer schreiben</p>
<pre><code class="language-cpp">int x[10000*sizeof(char)];
</code></pre>
<p><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/865377</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/865377</guid><dc:creator><![CDATA[Vorden]]></dc:creator><pubDate>Mon, 05 Sep 2005 12:25:01 GMT</pubDate></item><item><title><![CDATA[Reply to Zugriffsverletzung on Tue, 06 Sep 2005 08:41:25 GMT]]></title><description><![CDATA[<p>Besser ist es aber, man schreibt sich für sowas ein Makro.</p>
<pre><code class="language-cpp">#define CHAR_SIZE (1+sizeof(char)-1-sizeof(char)+1*1*sizeof(char)/1/sizeof(char))
int x[10000*CHAR_SIZE];
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/865958</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/865958</guid><dc:creator><![CDATA[groovemaster]]></dc:creator><pubDate>Tue, 06 Sep 2005 08:41:25 GMT</pubDate></item><item><title><![CDATA[Reply to Zugriffsverletzung on Tue, 06 Sep 2005 08:44:40 GMT]]></title><description><![CDATA[<p>würde es mit nem const int machen, da #define keine typprüfung macht, aber ansonsten ok</p>
]]></description><link>https://www.c-plusplus.net/forum/post/865963</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/865963</guid><dc:creator><![CDATA[Vorden]]></dc:creator><pubDate>Tue, 06 Sep 2005 08:44:40 GMT</pubDate></item><item><title><![CDATA[Reply to Zugriffsverletzung on Tue, 06 Sep 2005 09:41:12 GMT]]></title><description><![CDATA[<p>groovemaster schrieb:</p>
<blockquote>
<p>Besser ist es aber, man schreibt sich für sowas ein Makro.</p>
<pre><code class="language-cpp">#define CHAR_SIZE (1+sizeof(char)-1-sizeof(char)+1*1*sizeof(char)/1/sizeof(char))
int x[10000*CHAR_SIZE];
</code></pre>
</blockquote>
<p>Sehr umsichtiges define: Du solltest aber zusätzlich sicherstellen, daß <em>sizeof(char)</em> ungleich 0 ( Ziffer null == 1-1 ) ist! <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="🙂"
    /> (Divison durch null ist verboten )<br />
Außerdem bist DU dann maschinen und plattformunabahängig :p</p>
]]></description><link>https://www.c-plusplus.net/forum/post/866023</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/866023</guid><dc:creator><![CDATA[HannsW]]></dc:creator><pubDate>Tue, 06 Sep 2005 09:41:12 GMT</pubDate></item><item><title><![CDATA[Reply to Zugriffsverletzung on Tue, 06 Sep 2005 09:47:39 GMT]]></title><description><![CDATA[<p>groovemaster schrieb:</p>
<blockquote>
<p>Besser ist es aber, man schreibt sich für sowas ein Makro.</p>
<pre><code class="language-cpp">#define CHAR_SIZE (1+sizeof(char)-1-sizeof(char)+1*1*sizeof(char)/1/sizeof(char))
int x[10000*CHAR_SIZE];
</code></pre>
</blockquote>
<p>Poste sowas lieber nicht. Die Unerfahrenen kopieren sich das weil sie denken du meinst das ernst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/866038</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/866038</guid><dc:creator><![CDATA[.......]]></dc:creator><pubDate>Tue, 06 Sep 2005 09:47:39 GMT</pubDate></item><item><title><![CDATA[Reply to Zugriffsverletzung on Tue, 06 Sep 2005 10:07:45 GMT]]></title><description><![CDATA[<p>groovemaster schrieb:</p>
<blockquote>
<pre><code class="language-cpp">#define CHAR_SIZE (1+sizeof(char)-1-sizeof(char)+1*1*sizeof(char)/1/sizeof(char))
int x[10000*CHAR_SIZE];
</code></pre>
</blockquote>
<p>schon ne nette idee.<br />
ich finde es aber eleganzer, wenn man es so ansetzt:</p>
<pre><code class="language-cpp">#define CHAR_SIZE (sizeof(long)?sizeof(long int(&amp;)[10])/sizeof(unsigned long(&amp;)[10]):sizeof(short int(&amp;)[10])/sizeof(unsigned short(&amp;)[10]))
</code></pre>
<p>das hat zwei riesige vorteile:<br />
a) mit dem ?: wird erstmal gefragt, ob sizeof(long) überhaupt ungleich 0 ist, und falls sizeof(long) tatsächlich 0 ist, wird die gleiche berechnung mit short gemacht. das ist sehr sicher, da es zur zeit keinen compiler auf dem markt gibt, wo sizeof(long) und sizeof(short) beide 0 sein.<br />
b) ich benutze nicht wie du fahrlässigerweise sizeof(char), um doch nur sizeof(char) auszurechnen, um einem zirkelschluss zu entgehen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/866058</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/866058</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Tue, 06 Sep 2005 10:07:45 GMT</pubDate></item><item><title><![CDATA[Reply to Zugriffsverletzung on Tue, 06 Sep 2005 10:10:10 GMT]]></title><description><![CDATA[<p>lol</p>
<p>MfG SideWinder</p>
]]></description><link>https://www.c-plusplus.net/forum/post/866060</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/866060</guid><dc:creator><![CDATA[SideWinder]]></dc:creator><pubDate>Tue, 06 Sep 2005 10:10:10 GMT</pubDate></item><item><title><![CDATA[Reply to Zugriffsverletzung on Tue, 06 Sep 2005 10:11:53 GMT]]></title><description><![CDATA[<p>Darf ich auch mal?</p>
<pre><code class="language-cpp">#define CHAR_SIZE 1
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/866062</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/866062</guid><dc:creator><![CDATA[FireFlow]]></dc:creator><pubDate>Tue, 06 Sep 2005 10:11:53 GMT</pubDate></item><item><title><![CDATA[Reply to Zugriffsverletzung on Tue, 06 Sep 2005 10:37:02 GMT]]></title><description><![CDATA[<p>FireFlow schrieb:</p>
<blockquote>
<p>Darf ich auch mal?</p>
<pre><code class="language-cpp">#define CHAR_SIZE 1
</code></pre>
</blockquote>
<p>das ergibt gar keinen sinn, weil:<br />
a) man dann immer 1 statt CHAR_SIZE schreiben würde und CHAR_SIZE unnötig wäre.<br />
b) du dich auf eine zusage beziehst, die bei fehlerhaften compiler nicht immer verläßlich sein muß.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/866066</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/866066</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Tue, 06 Sep 2005 10:37:02 GMT</pubDate></item><item><title><![CDATA[Reply to Zugriffsverletzung on Tue, 06 Sep 2005 17:30:30 GMT]]></title><description><![CDATA[<p>OK volkard, hast mich überzeugt. Deine Methode ist tatsächlich besser, und zudem eleganter.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/866448</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/866448</guid><dc:creator><![CDATA[groovemaster]]></dc:creator><pubDate>Tue, 06 Sep 2005 17:30:30 GMT</pubDate></item><item><title><![CDATA[Reply to Zugriffsverletzung on Tue, 06 Sep 2005 17:35:50 GMT]]></title><description><![CDATA[<p>ROFL <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="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/866452</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/866452</guid><dc:creator><![CDATA[Walli]]></dc:creator><pubDate>Tue, 06 Sep 2005 17:35:50 GMT</pubDate></item></channel></rss>