Addition of pointers

David Goodenough dg at lakart.UUCP
Wed May 10 00:09:35 AEST 1989


>From article <2299 at mit-caf.MIT.EDU>, by vlcek at mit-caf.MIT.EDU (Jim Vlcek):
> In article <4093 at ficc.uu.net> peter at ficc.uu.net (Peter da Silva) writes:
>>In article <563 at lzaz.ATT.COM>, hutch at lzaz.ATT.COM (R.HUTCHISON) writes:
>>> 	midpoint_pointer = (start_pointer + end_pointer) / 2;
>>
>>You're right. It's a valid operation.
> 
> In what sense?  It's invalid C, that's for sure.
> 
> All you people who want to be able to add pointers, consider this:
> What is the significance of the sum of ``the location of Boston'' and
> ``the location of Detroit?''  Answer: none.

Taking this to it's (logical??????) conclusion, is not the point half way
between Boston and Detroit (say Elmira in Upstate NY :-) ) best defined
as:

Start at Boston, and go 1/2 way to Detroit, or in pointer arithmetic:

 	midpoint_pointer = start_pointer + (end_pointer - start_pointer) / 2;

Now, in scalar maths this is the same as the formula above, but pointers
are _NOT_ scalars: adjusting the formula again:

	midpoint_pointer = start_pointer / 2 + end_pointer / 2;

Now, just what the hell is half a pointer???????
-- 
	dg at lakart.UUCP - David Goodenough		+---+
						IHS	| +-+-+
	....... !harvard!xait!lakart!dg			+-+-+ |
AKA:	dg%lakart.uucp at xait.xerox.com		  	  +---+



More information about the Comp.lang.c mailing list