Xref: utzoo comp.lang.c:6807 comp.sys.m68k:689 Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!ihlpf!nevin1 From: nevin1@ihlpf.ATT.COM (00704a-Liber) Newsgroups: comp.lang.c,comp.sys.m68k Subject: Re: C machine Message-ID: <3527@ihlpf.ATT.COM> Date: 28 Jan 88 01:26:24 GMT References: <7092@brl-smoke.ARPA> <1186@cooper.cooper.EDU> Reply-To: nevin1@ihlpf.UUCP (00704a-Liber,N.J.) Organization: AT&T Bell Laboratories - Naperville, Illinois Lines: 33 In article <1186@cooper.cooper.EDU> gene@cooper.cooper.EDU (Gene (the Spook)) writes: .Take the example of an offset from a pointer. If, for example, you have . . p1 = p0[d] . .This would be interpreted as . . (ptr) p1 = (ptr) p0 + (int) d Actually, I thought that 'p1 = p0[d]' is interpreted as (ptr) p1 = (ptr) p0 + (long) (d * sizeof(type p0)) assuming long can hold all possible additions to pointers. .Simply, add an integer displacement to a pointer, and you'll get another .pointer. With a little algebra, solve for 'd'. You'll get . . (int) d = (ptr) p1 - (ptr) p0 . .This is simply solving for the displacement. What else could it be??? FIrst off, d should be a long, not an int. A possibility for what d should be is the value that makes p0[d] === p1. (I am not suggesting that this happen) .I think the K&R solution is just fine the way it is. 100% agreement here. -- _ __ NEVIN J. LIBER ..!ihnp4!ihlpf!nevin1 (312) 510-6194 ' ) ) "The secret compartment of my ring I fill / / _ , __o ____ with an Underdog super-energy pill." / (_