ints vs. pointers

Henry Spencer henry at utzoo.UUCP
Sun Nov 11 12:38:16 AEST 1984

> [Quoting K&R:]
> 	If two pointers of the same type are subtracted, the result is con-
> 	verted (by division by the length of the object) to an int representing
> 	the number of objects separating the pointed-to objects.
> [Hence pointers cannot be larger than ints.]

The explicit use of "int" here is now generally considered a mistake.
The ANSI draft (17 Oct 1984 draft) says that the result is a signed
integer of implementation-dependent size, i.e. it would be wise to use
a long if you need to hold such a result.
				Henry Spencer @ U of Toronto Zoology

More information about the Comp.lang.c mailing list