Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!zephyr.ens.tek.com!uw-beaver!ubc-cs!alberta!dvinci!fogel From: fogel@dvinci.usask.ca (Earl Fogel) Newsgroups: comp.lang.c Subject: Re: Pointer arithmetic and comparisons. Message-ID: <1989Dec15.153806.29836@dvinci.usask.ca> Date: 15 Dec 89 15:38:06 GMT References: <257ECDFD.CDD@marob.masa.com> Reply-To: fogel@dvinci.UUCP (Earl Fogel) Organization: University of Saskatchewan, Saskatoon, Canada Lines: 17 daveh@marob.masa.com (Dave Hammond) writes: >Machine/OS: 286-compatible/MSDOS >Compiler: Turbo-C 1.5 > >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 ? > The problem, I believe, is in the Memory Model you are using in Turbo C. If your data does not all fit into one 65535 byte segment, then you have to declare pointers to be 'huge' for them to properly address your buffer.