a[], *p: if 0 <= p - a < sizeof(a), must p point to an element of a?

brnstnd at stealth.acf.nyu.edu brnstnd at stealth.acf.nyu.edu
Fri Jan 5 05:39:53 AEST 1990


Basically, I want to have a guaranteed test of whether p points to an
element of a, with foo a[N] and foo *p. I know that *if* p points to an
element of a, *then* 0 <= p - a < sizeof(a); is the reverse true? (If
yes, please explain the logic.)

The standard should define pointer subtraction more carefully.

---Dan



More information about the Comp.std.c mailing list