<?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[Frage zu seltsamem Indexoperator]]></title><description><![CDATA[<p>Hallo, ich habe folgenden Code gefunden:</p>
<pre><code class="language-cpp">char c = 0[&quot;abc&quot;];
std::cout&lt;&lt;c; //ausgabe a
</code></pre>
<p>Wie funktioniert das? Versteht mich nicht falsch, ich kann durchaus mit (C-)arrays und index operatoren umgehen, aber was genau geschieht in dem Beispiel? Ich hätte den Code so geschrieben:</p>
<pre><code class="language-cpp">char c = &quot;abc&quot;[0];
</code></pre>
<p>Wie kann denn ein &quot;const char ponter&quot; als &quot;index&quot; fungieren? und wieso ist die 0 davor syntaktisch erlaubt?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/280985/frage-zu-seltsamem-indexoperator</link><generator>RSS for Node</generator><lastBuildDate>Sun, 23 Aug 2026 21:36:02 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/280985.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 25 Jan 2011 01:50:54 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Frage zu seltsamem Indexoperator on Tue, 25 Jan 2011 01:50:54 GMT]]></title><description><![CDATA[<p>Hallo, ich habe folgenden Code gefunden:</p>
<pre><code class="language-cpp">char c = 0[&quot;abc&quot;];
std::cout&lt;&lt;c; //ausgabe a
</code></pre>
<p>Wie funktioniert das? Versteht mich nicht falsch, ich kann durchaus mit (C-)arrays und index operatoren umgehen, aber was genau geschieht in dem Beispiel? Ich hätte den Code so geschrieben:</p>
<pre><code class="language-cpp">char c = &quot;abc&quot;[0];
</code></pre>
<p>Wie kann denn ein &quot;const char ponter&quot; als &quot;index&quot; fungieren? und wieso ist die 0 davor syntaktisch erlaubt?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2011621</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2011621</guid><dc:creator><![CDATA[IndexWeird]]></dc:creator><pubDate>Tue, 25 Jan 2011 01:50:54 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu seltsamem Indexoperator on Tue, 25 Jan 2011 02:01:30 GMT]]></title><description><![CDATA[<p>Steht halt im Standard so drin:</p>
<p>ISO/IEC 14882:2003 5.2.1 (1) schrieb:</p>
<blockquote>
<p>A postfix expression followed by an expression in square brackets is a postfix expression. One of the expressions shall have the type “pointer to T” and the other shall have enumeration or integral type. The result is an lvalue of type “T.” The type “T” shall be a completely-defined object type. *<em>The expression E1[E2] is identical (by definition) to <em>((E1)+(E2)).</em></em> [Note: see 5.3 and 5.7 for details of * and + and 8.3.4 for details of arrays. ]</p>
</blockquote>
<p>(Hervorhebung von mir)</p>
<p>&quot;abc&quot;[0] und 0[&quot;abc&quot;] machen also genau das selbe.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2011622</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2011622</guid><dc:creator><![CDATA[seldon]]></dc:creator><pubDate>Tue, 25 Jan 2011 02:01:30 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu seltsamem Indexoperator on Tue, 25 Jan 2011 11:15:41 GMT]]></title><description><![CDATA[<p>Der []-operator addiert nur eine Addresse.<br />
Deshalb ist a[b] und b[a] dasselbe.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2011730</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2011730</guid><dc:creator><![CDATA[314159265358979]]></dc:creator><pubDate>Tue, 25 Jan 2011 11:15:41 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu seltsamem Indexoperator on Tue, 25 Jan 2011 18:34:39 GMT]]></title><description><![CDATA[<p>ist das auch bei<br />
a[2][4]<br />
und<br />
4[2][a]<br />
so?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2012129</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2012129</guid><dc:creator><![CDATA[bubble 3566]]></dc:creator><pubDate>Tue, 25 Jan 2011 18:34:39 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu seltsamem Indexoperator on Tue, 25 Jan 2011 18:47:28 GMT]]></title><description><![CDATA[<p>bubble 3566 schrieb:</p>
<blockquote>
<p>ist das auch bei<br />
a[2][4]<br />
und<br />
4[2][a]<br />
so?</p>
</blockquote>
<p>Rechne es doch aus! Addieren wirst du doch wohl noch können.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2012135</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2012135</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Tue, 25 Jan 2011 18:47:28 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu seltsamem Indexoperator on Tue, 25 Jan 2011 18:59:06 GMT]]></title><description><![CDATA[<p>bubble 3566 schrieb:</p>
<blockquote>
<p>ist das auch bei<br />
a[2][4]<br />
so?</p>
</blockquote>
<p>2[a][4],<br />
4[a[2&rsqb;&rsqb;,<br />
4[2[a&rsqb;&rsqb;</p>
<p>( alles äquivalent zu a[2][4] )</p>
<p>und 4[2][a] kompiliert genauso wenig wie (*(4+2))[a]</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2012136</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2012136</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Tue, 25 Jan 2011 18:59:06 GMT</pubDate></item></channel></rss>