Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!kddlab!titcca!sragwa!wsgw!socslgw!diamond!diamond From: diamond@diamond.csl.sony.junet (Norman Diamond) Newsgroups: comp.lang.c Subject: Re: Adding two pointers Message-ID: <10229@socslgw.csl.sony.JUNET> Date: 8 May 89 05:17:26 GMT References: <2765@buengc.BU.EDU> <563@lzaz.ATT.COM> <4093@ficc.uu.net> <17340@mimsy.UUCP> <4646@freja.diku.dk> Sender: news@csl.sony.JUNET Reply-To: diamond@csl.sony.junet (Norman Diamond) Organization: /usr/lib/news/organization Lines: 32 In article <4646@freja.diku.dk> njk@freja.diku.dk (Niels J|rgen Kruse) writes: >What about > >struct { > char c; > double d; >} x[10]; > >Are (& x[3].d) and (& x[7].d) not pointing into x? They point "into" x, yes, as far as the English language is concerned. But they do not point to ELEMENTS OF x. You have to read technicalese more carefully than ordinary English. >Is (& x[3].d - x[7].d) undefined? I think you mean (& x[3].d - & x[7].d). Again, when you read the technicalese carefully enough, you find that the answer is yes (maybe surprisingly). >What array is (char *)x pointing into? Any pointer can be cast to a (char *) pointer and back to its original type, but the (char *) version doesn't have to have a legal meaning. If you dereference it, you might get a core dump or worse. -- Norman Diamond, Sony Computer Science Lab (diamond%csl.sony.co.jp@relay.cs.net) The above opinions are my own. | Why are programmers criticized for If they're also your opinions, | re-inventing the wheel, when car you're infringing my copyright. | manufacturers are praised for it?