Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!ames!lll-winken!xanth!kremer From: kremer@cs.odu.edu (Lloyd Kremer) Newsgroups: comp.lang.c Subject: Re: Another silly question Summary: they're defined to be identical Message-ID: <8662@xanth.cs.odu.edu> Date: 27 Apr 89 16:04:20 GMT References: pointer array reference access element <2459@nmtsun.nmt.edu> Organization: Old Dominion University, Norfolk, Va. Lines: 36 In article <2459@nmtsun.nmt.edu> kelly@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!