Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!ames!lll-winken!uunet!mcvax!hp4nl!botter!star.cs.vu.nl!sater From: sater@cs.vu.nl (Hans van Staveren) Newsgroups: comp.lang.c Subject: Re: Another silly question Keywords: C, history, anecdotal Message-ID: <2425@sater.cs.vu.nl> Date: 1 May 89 10:41:46 GMT References: <2459@nmtsun.nmt.edu> <1513@auspex.auspex.com> Reply-To: sater@cs.vu.nl (Hans van Staveren) Organization: VU Informatica, Amsterdam Lines: 32 In article <1513@auspex.auspex.com> guy@auspex.auspex.com (Guy Harris) 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] > /* LOTS OF STUFF DELETED */ >You are correct; he is incorrect. Perhaps he does not understand how >pointer addition works in C? If you add an integral value N to a pointer, >it doesn't increment the address in that pointer by N storage units >(bytes on byte addressible machine, etc.), it can be thought of as >incrementing the address by N objects of the type to which that pointer >points. In C, pointers have types, and those types are significant. Just to show how old I am, let me tell you that in Unix V6 on the PDP 11, the only machine it ran on, the expressions a + i and i + a with a a pointer and i an integer were not equivalent. a + i worked as it does nowadays while i + a worked as this guys instructor fears. I am even willing to admit I used this trick, but then in those days the way to get an unsigned was to declare it as a char* and casts were not invented yet. Language historians, take note! Hans van Staveren Vrije Universiteit Amsterdam, Holland