Xref: utzoo comp.sys.ibm.pc:22713 comp.sys.intel:634 Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!ukma!rutgers!elbereth.rutgers.edu!ron.rutgers.edu!ron From: ron@ron.rutgers.edu (Ron Natalie) Newsgroups: comp.sys.ibm.pc,comp.sys.intel Subject: Re: correct code for pointer subtraction Keywords: C pointer math DAMN WELL IS A BUG!!!! Message-ID: Date: 3 Jan 89 17:44:57 GMT References: <597@mks.UUCP> <3845@pt.cs.cmu.edu> <18123@santra.UUCP> <142@bms-at.UUCP> <6604@killer.DALLAS.TX.US> Organization: Rutgers Univ., New Brunswick, N.J. Lines: 7 > sizeof(int) == 2 > so 30000 * 2 =60000 which is to large for a signed int Sizeof is irrelevent for pointer math. For subtraction, The result is the number of "elements" which would be 30000, not 30000 times sizeof int. For addition, the result is a new pointer, incremented by the number of elements of the integer added to the pointer.