Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!mcvax!ukc!kl-cs!pc From: pc@cs.keele.ac.uk (Phil Cornes) Newsgroups: comp.lang.c Subject: Re: Another silly question Message-ID: <607@kl-cs.UUCP> Date: 16 May 89 17:22:28 GMT References: <17812@cup.portal.com> Organization: University of Keele, England Lines: 21 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. > If I mix two pointer types, as in > char * c; > long * ell; > return c + ell; > is this anarchy? Is it a syntax error? What is sizeof(*(c+ell))? > In this case the question doesn't make sense because the addition operators function is undefined for two pointer type operands....