Addition of pointers

Roemer Lievaart roemer at cs.vu.nl
Tue May 9 03:03:29 AEST 1989


vlcek at mit-caf.MIT.EDU (Jim Vlcek) writes:

>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.

It is not. It is a wrong way to write:
	midpoint_pointer = start_pointer + (end_pointer - start_pointer) / 2;

>In what sense?  It's invalid C, that's for sure.

It's invalid anyway: addition of pointers is in general nonsense.
It may make sense to take the average of two pointers, but not by defining
it in ways of two senseless operations (on pointers): addition and division.
____________________________________________________________________________
Roemer B. Lievaart | "Wa:a:na:a: das Soogo! Schnell!" "GRONF!" "Ich krich die
Amsterdam, Holland | Packung nicht auf!" "Gargll" "Da:s woo ho:o:ste Oisnbohn,
roemer at cs.vu.nl    | Das woissu ja wohl!"    -- Bro:sel, "Werner, Normal Ja!"



More information about the Comp.lang.c mailing list