<?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[Typ für Zeiger weiterzählen, und Typ für Array Index]]></title><description><![CDATA[<p>Ist es guter Stil, wenn ich bei Zeigern den Typ &quot;ptrdiff_t&quot; verwende:</p>
<pre><code class="language-cpp">int array[10] = {0};
int *p = array;
ptrdiff_t interval= 4;
cout &lt;&lt; *(p+interval) &lt;&lt; endl;
//bzw.
cout &lt;&lt; p[interval] &lt;&lt; endl;
</code></pre>
<p>und bei Arrays den Typ &quot;size_t&quot;:</p>
<pre><code class="language-cpp">int array[10] = {0};
size_t index = 3;
cout &lt;&lt; array[index] &lt;&lt; endl;
</code></pre>
<p>So ging dass aus meinem Buch hervor, wenn ichs richtig verstanden habe. Eure Meinung, wie macht ihr dass?</p>
<p>MfG<br />
Stromberg</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/234185/typ-für-zeiger-weiterzählen-und-typ-für-array-index</link><generator>RSS for Node</generator><lastBuildDate>Thu, 24 Sep 2026 12:49:17 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/234185.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 14 Feb 2009 11:59:31 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Typ für Zeiger weiterzählen, und Typ für Array Index on Sat, 14 Feb 2009 12:01:14 GMT]]></title><description><![CDATA[<p>Ist es guter Stil, wenn ich bei Zeigern den Typ &quot;ptrdiff_t&quot; verwende:</p>
<pre><code class="language-cpp">int array[10] = {0};
int *p = array;
ptrdiff_t interval= 4;
cout &lt;&lt; *(p+interval) &lt;&lt; endl;
//bzw.
cout &lt;&lt; p[interval] &lt;&lt; endl;
</code></pre>
<p>und bei Arrays den Typ &quot;size_t&quot;:</p>
<pre><code class="language-cpp">int array[10] = {0};
size_t index = 3;
cout &lt;&lt; array[index] &lt;&lt; endl;
</code></pre>
<p>So ging dass aus meinem Buch hervor, wenn ichs richtig verstanden habe. Eure Meinung, wie macht ihr dass?</p>
<p>MfG<br />
Stromberg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1663669</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1663669</guid><dc:creator><![CDATA[Stromberg]]></dc:creator><pubDate>Sat, 14 Feb 2009 12:01:14 GMT</pubDate></item><item><title><![CDATA[Reply to Typ für Zeiger weiterzählen, und Typ für Array Index on Sat, 14 Feb 2009 12:56:52 GMT]]></title><description><![CDATA[<p>Also eine Kurzbeschreibung über ptrdiff_t findest du hier:</p>
<p><a href="http://www.cplusplus.com/reference/clibrary/cstddef/ptrdiff_t.html" rel="nofollow">http://www.cplusplus.com/reference/clibrary/cstddef/ptrdiff_t.html</a></p>
<p>und hier eine kleine Diskussion drüber, die - wie ich finde - recht gut ist.</p>
<p><a href="http://www.velocityreviews.com/forums/t449159-when-should-i-use-ptrdifft-and-sizet-instead-of-int-and-unsigned-int.html" rel="nofollow">http://www.velocityreviews.com/forums/t449159-when-should-i-use-ptrdifft-and-sizet-instead-of-int-and-unsigned-int.html</a></p>
<p>/Edit:<br />
Guter Stil ist so eine Sache. In deinem Beispiel würde ich schon deshalb nicht ptrdiff_t nehmen, da es sich nicht um das Resultat einer Zeigersubtraktion handelt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1663699</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1663699</guid><dc:creator><![CDATA[Paul Manns]]></dc:creator><pubDate>Sat, 14 Feb 2009 12:56:52 GMT</pubDate></item><item><title><![CDATA[Reply to Typ für Zeiger weiterzählen, und Typ für Array Index on Sat, 14 Feb 2009 13:14:20 GMT]]></title><description><![CDATA[<p>was würdest du dann nehmen? &quot;int&quot;?</p>
<p>MfG<br />
Stromberg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1663709</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1663709</guid><dc:creator><![CDATA[Stromberg]]></dc:creator><pubDate>Sat, 14 Feb 2009 13:14:20 GMT</pubDate></item><item><title><![CDATA[Reply to Typ für Zeiger weiterzählen, und Typ für Array Index on Sat, 14 Feb 2009 13:21:45 GMT]]></title><description><![CDATA[<p>ich persönlich würde am liebsten int nehmen...<br />
das ist doch das logischte oder? weil int für eine (An-)Zahl steht</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1663714</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1663714</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sat, 14 Feb 2009 13:21:45 GMT</pubDate></item><item><title><![CDATA[Reply to Typ für Zeiger weiterzählen, und Typ für Array Index on Sat, 14 Feb 2009 13:26:56 GMT]]></title><description><![CDATA[<p>Mh aber sagen wir so, wenn mir ptrdiff_t gefällt, und ichs verwende, dann ist es nicht falsch oder schlechter Stil?</p>
<p>MfG<br />
Stromberg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1663719</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1663719</guid><dc:creator><![CDATA[Stromberg]]></dc:creator><pubDate>Sat, 14 Feb 2009 13:26:56 GMT</pubDate></item><item><title><![CDATA[Reply to Typ für Zeiger weiterzählen, und Typ für Array Index on Sat, 14 Feb 2009 14:39:13 GMT]]></title><description><![CDATA[<p>Stromberg schrieb:</p>
<blockquote>
<p>Mh aber sagen wir so, wenn mir ptrdiff_t gefällt, und ichs verwende, dann ist es nicht falsch oder schlechter Stil?</p>
<p>MfG<br />
Stromberg</p>
</blockquote>
<p>Es ist daher &quot;schlechter&quot; Stil, weil es nicht für das gedacht ist. Und daher macht es nicht wirklich Sinn. Es geht wahrscheinlich meistens gut, aber das heisst nichts.. Den konzipiert sind solche Typen ja nicht für normale Fälle, sondern für Ausnahmen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1663756</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1663756</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Sat, 14 Feb 2009 14:39:13 GMT</pubDate></item><item><title><![CDATA[Reply to Typ für Zeiger weiterzählen, und Typ für Array Index on Sat, 14 Feb 2009 14:49:47 GMT]]></title><description><![CDATA[<p>Aha, okay dann nehme ich &quot;int&quot;.</p>
<p>MfG<br />
Stromberg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1663760</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1663760</guid><dc:creator><![CDATA[Stromberg*]]></dc:creator><pubDate>Sat, 14 Feb 2009 14:49:47 GMT</pubDate></item></channel></rss>