Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!lll-tis!ames!rutgers!princeton!udel!burdvax!sdcrdcf!ism780c!news From: news@ism780c.UUCP (News system) Newsgroups: comp.lang.c Subject: Re: Pointers and Arrays (was: C machine) Message-ID: <8823@ism780c.UUCP> Date: 2 Feb 88 00:08:36 GMT References: <461@auvax.UUCP> <28700025@ccvaxa> <7159@brl-smoke.ARPA> <8728@ism780c.UUCP> <3546@ihlpf.ATT.COM> <1329@laidbak.UUCP> Reply-To: marv@ism780.UUCP (Marvin Rubenstein) Organization: Interactive Systems Corp., Santa Monica CA Lines: 29 I got lost in all the >'s I (Marv Rubinstein) wrote: BTW, the definition of pointer difference in K&R is "if p and q point to members of the same array , p-q is the number of elements between p and q." Some one else wrote: >I opened up my K&R, skimmed all of chapter 5 (Pointers and Arrays), and could >not find this anywhere! (Maybe I didn't look hard enough :-)) I don't think >this is how K&R defined it (see more comments below). You didn't :-) Perhaps you should have looked in the index first. In the index on page 226 one finds the entry: "pointer subtraction 98" On page 98 one finds in the last paragraph: "Pointer subtraction is also valid: if p and q point to members of the same array , p-q is the number of elements between p and q." My reason for bring up this whole issue was to point out the the term "between" used here is fuzzy and could lead one to confusion. I was just asking if the language in the standard was less ambigious. (Doug answered that it is less ambigious). Also I once had to correct a compiler that was implemented such that p-q was the same as q-p (p and q pointers to the same array). When I found the wording on page 98 I asked several colleagues "how many integers are there between 1 and 3 and how many integers are there between 3 and 1?" most answered "one" to both questions. Marv Rubinstein. -- Interactive Systeme