Sujet : Re: do { quit; } else { }
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.lang.cDate : 14. Apr 2025, 02:33:17
Autres entêtes
Organisation : None to speak of
Message-ID : <87h62r4jdu.fsf@nosuchdomain.example.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
User-Agent : Gnus/5.13 (Gnus v5.13)
James Kuyper <
jameskuyper@alumni.caltech.edu> writes:
On 4/13/25 17:30, Michael S wrote:
...
My impression rfrom old books was that indexing as [i]arr was (is ?)
also legal.
>
If it had ever been legal, I would have expected it to be mentioned in
K&R 1st edition, in the section where it describes obsolete syntax that
used to be valid. It isn't.
It isn't mentioned there because the syntax isn't obsolete.
It's mentioned in K&R1 Appendix A section 14.3, page 210:
By definition, the subscript operator [] is interpreted in such a
way that E1 [E2] is identical to *((E1)+(E2)). Because of the
conversion rules which apply to +, if E1 is an array and E2 an
integer, then E1 [E2] refers to the E2-th member of E1. Therefore,
despite its asymmetric appearance, subscripting is a commutative
operation.
This is still true in all editions up to and including C23.
-- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.comvoid Void(void) { Void(); } /* The recursive call of the void */