Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!pasteur!ucbvax!husc6!xait!g-rh From: g-rh@xait.CCA.COM (Richard Harter) Newsgroups: comp.lang.c Subject: Re: Array indexing vs. pointers... Message-ID: <33488@xait.CCA.COM> Date: 19 Sep 88 19:57:16 GMT References: <8809191521.AA17824@ucbvax.Berkeley.EDU> Reply-To: g-rh@XAIT.Xerox.COM (Richard Harter) Organization: Xerox Corporation, Cambridge, Massachusetts Lines: 39 In article <8809191521.AA17824@ucbvax.Berkeley.EDU> U23405@UICVM (Michael J. Steiner) writes: >First, I have a question. How and why is array indexing slower than >pointer arithmetic? They are very similar. Also, I think that compilers >should automatically translate array indexing into pointer arithmetic when >dealing with arrays in C. Any comments, opinions? Depends on the compiler, the machine, and the circumstances. The gain comes when you increment a pointer into the array rather than reference the indexed array. For example for (i=0;i