Pointers and Arrays

Chris Torek chris at mimsy.UUCP
Sun Jan 31 15:36:20 AEST 1988

In article <1329 at laidbak.UUCP> daveb at laidbak.UUCP (Dave Burton) writes:
>K&R, Chapter 5, page 98, Paragraph just above last example:
>"Pointer subtraction is also valid: if p and q point to members of the
> same array, p-q is the number of elements between p and q."

This section of K&R is descriptive, not prescriptive.  What does
the appendix have to say?

At any rate, the number of elements `between' p and q (via p-q) in

	| 0 | 1 | 2 | 3 |
	 q       p

is easily seen as -2, if you just turn your brain around. :-)
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris

More information about the Comp.lang.c mailing list