Pointer arithmetic and comparisons.
T. William Wells
bill at twwells.com
Mon Dec 11 19:13:46 AEST 1989
In article <232 at bohra.cpg.oz> ejp at bohra.UUCP (Esmond Pitt) writes:
: That's because the last element is not &buffer[last] but &buffer[last-1],
: and so you should test for <= &buffer[last-1], not < &buffer[last].
: You are incrementing a pointer to point outside the object, and this is
: not guaranteed to work under _any_ implementation of C.
Not only is this going to work in most implementations, it is
*required* to work by the ANSI standard.
My guess is that his object is exactly 64K bytes long and he is
running into the silly segmentation problems of the 8086. There
are two fixes: use an object of no more than 64K-1 bytes or use
whatever model it is that does the right thing with objects of
size 64K and larger.
---
Bill { uunet | novavax | ankh | sunvice } !twwells!bill
bill at twwells.com
More information about the Comp.lang.c
mailing list