Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!hplabs!pyramid!infmx!kevinf From: kevinf@infmx.UUCP (Kevin Franden) Newsgroups: comp.lang.c Subject: Re: Adding two pointers Message-ID: <1321@infmx.UUCP> Date: 10 May 89 19:50:27 GMT References: <2765@buengc.BU.EDU> <563@lzaz.ATT.COM> <4093@ficc.uu.net> <922@garcon.cso.uiuc.edu> <924@garcon.cso.uiuc.edu> <113@ssp1.idca.tds.philips.nl> Reply-To: kevinf@infmx.UUCP (Kevin Franden) Organization: Informix, Menlo Park, Ca. U.S.A. Lines: 37 Assuming that there does exist an application that wnats/needs to add pointers, why won't this 'model' work? Assume an array a to be made up of elements of arbitrary size. Assume further that this array has 100 elements arranged (as we know C does) contiguously in memory. if p1 is pointing to element 37 and p2 is pointing to element 4, I'd like p3 to point to a[37+4] or a[41]. struct{...}foo; foo p1,p2,p3; x=37; y=4; p1=a[x]; p2=a[y]; p3=(x+y)*sizeof(foo); I realize that I missed part of this discussion, sorry if this has been posted already, but won't p3 be pointing to the 41st element? if this is true, this is pointer addition, no? -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Kevin Franden UUCP: {backbone}!pyramid!infmx!kevinf Informix Software Inc disclaimer("I said what I said and not my employer"); =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Cocaine: The big lie. OS/2: The BIG hack.