Pointer arithmetic and comparisons.

c9h at psuecl.bitnet c9h at psuecl.bitnet
Fri Dec 8 12:36:25 AEST 1989


In article <257ECDFD.CDD at marob.masa.com>, daveh at marob.masa.com (Dave Hammond) writes:
> The problem occurs when the address resulting from &buffer[len] exceeds
> 65535.  For example, if &buffer[0] is 65535 and len is 100, &buffer[len]
> becomes 99, making `while (p < e)' immediately false.
>
> I was under the impression that (for n > 0) buffer[n] should not yield
> an address lower than buffer[0].  Is the pointer comparison I am doing
> non-portable, or otherwise ill-advised ?

This will *only* occur if you are accessing an element outside of the
array's boundaries.

--
- Charles Martin Hannum II       "Klein bottle for sale ... inquire within."
    (That's Charles to you!)     "To life immortal!"
  c9h at psuecl.{bitnet,psu.edu}    "No noozzzz izzz netzzzsnoozzzzz..."
  cmh117 at psuvm.{bitnet,psu.edu}  "Mem'ry, all alone in the moonlight ..."



More information about the Comp.lang.c mailing list