Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!njin!princeton!njsmu!mccc!pjh From: pjh@mccc.UUCP (Pete Holsberg) Newsgroups: comp.lang.c Subject: Re: Another silly question Message-ID: <749@mccc.UUCP> Date: 18 May 89 19:34:54 GMT References: <17812@cup.portal.com> <607@kl-cs.UUCP> Reply-To: pjh@mccc.UUCP (Pete Holsberg) Organization: The College On The Other Side of U. S. Route 1 Lines: 16 In article <607@kl-cs.UUCP> pc@cs.keele.ac.uk (Phil Cornes) writes: =From article <17812@cup.portal.com>, by Tim_CDC_Roberts@cup.portal.com: => Ok, folks. In regards to "a[i] == *(a+i) == *(i+a) == i[a]", let me => refer to the oft-used example 2["hello"]. => I agree that this works and is equivalent to "hello"[2]. I've seen it => in books and postings. My simple question is why? = =C does not really support arrays, and the square bracket operator ([]) is =just syntactic sugar to make you think that it does! This works quite well =until you see things like "hello"[2] == 2["hello"] which only look odd if =you continue to think of them as arrays and not pointers. Can you explain why compilers produce different code for "a[i]" and "*(a+i)"? Thanks. -- Pete Holsberg, Mercer County Community College, Trenton, NJ 08690