3 ms·
>Accessing an element of an array via ptr[3] is actually just short for (ptr + 3). This can be equivalently written as (3 + ptr) and therefore as 3[ptr], which
by topkekz 10y ago
>Accessing an element of an array via ptr[3] is actually just short for (ptr + 3). This can be equivalently written as (3 + ptr) and therefore as 3[ptr], which turns out to be completely valid code.
C++ standard defines the syntax of a postfix expression as this
postfix-expression:
primary-expression
postfix-expression[expression]
postfix-expression[braced-init-list]
[expression]primary-expression is not valid