When it is amoral... (Re: When is a cast not a cast?)
R.HUTCHISON
hutch at lzaz.ATT.COM
Fri May 5 23:00:56 AEST 1989
Re: addition of two pointers
How 'bout in a binary search to find the middle char in an array of
characters?
midpoint_pointer = (start_pointer + end_pointer) / 2;
Yes, I realize that you can...
midpoint_pointer = ((end_pointer - start_pointer) / 2) + start_pointer;
... but I think people were asking when you might ever want to add two
pointers and where it could possibly me meaningful. After all, if the
two variables were not pointers and represented distances (in feet)
and I wanted the midpoint, I might choose the first approach.
Bob Hutchison
lzaz!hutch
More information about the Comp.lang.c
mailing list