Another silly question
Lloyd Kremer
kremer at cs.odu.edu
Fri Apr 28 02:04:20 AEST 1989
In article <2459 at nmtsun.nmt.edu> kelly at nmtsun.nmt.edu (Sean Kelly) writes:
>My CS instructor and I disagree about a certain moot point. I have a text
>book which says that
>
> *(a + i) and a[i]
>
>are equivalent, given an array a, and int index i ... each gives the
>value stored in a[i]. But he says that
>
> *(a + i)
>
>is non-standard and would not expect it do go far on all _real_ C compilers
The expressions *(a + i) and a[i] are absolutely synonymous in every way.
Either one could be defined as the other. This fact is one of the foundational
pillars of the C Language.
Any C compiler that does not agree with this lacks knowledge of the most basic
fundamentals of the language and does not deserve to be called a C compiler.
I am tempted to make analogous remarks about C instructors.
An interesting corollary of this rule, often used in intentionally obfuscated
code, is:
a[i] == *(a + i) == *(i + a) == i[a]
Ask your instructor what he thinks 1["hello"] will evaluate to!
--
Lloyd Kremer
Brooks Financial Systems
...!uunet!xanth!brooks!lloyd
Have terminal...will hack!
More information about the Comp.lang.c
mailing list