Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!cuae2!ihnp4!inuxc!pur-ee!uiucdcs!uxc.cso.uiuc.edu!uicsrd!konigsfe From: konigsfe@uicsrd.UUCP Newsgroups: comp.sys.ibm.pc Subject: Re: Bug in Microsoft C 4.00? Message-ID: <42900003@uicsrd> Date: Sun, 15-Feb-87 17:09:00 EST Article-I.D.: uicsrd.42900003 Posted: Sun Feb 15 17:09:00 1987 Date-Received: Wed, 18-Feb-87 21:57:30 EST References: <216700008@orstcs> Lines: 26 Nf-ID: #R:orstcs:216700008:uicsrd:42900003:000:1124 Nf-From: uicsrd.CSRD.UIUC.EDU!konigsfe Feb 15 16:09:00 1987 > printf("address of array1 is %x, end of array1 is %x\n", > array1, array1+sizeof(array1)); As I see it, there is nothing wrong with the compiler or linker but just your (or maybe its mine) perception of what the compiler is doing. In the above code array1 was an array of integers with 100 elements. This gives it a size of 200 bytes. It appears that array1+sizeof(array1) should give the address of array1 plus 200, but the compiler will assume that you are giving an offset to an integer pointer, array1, and really add 2 for every integer offset. In other words the compiler multiplies the pointer offset (sizeof(array1)) by the size of element pointed to by array1 (sizeof(int) = 2) and therefore adds 400 instead of 200. If this explination is wrong, please let me know because much of my code will need to be reevaluated. Disclaimer: I don't claim to be smart, I've just failed enough times to make me learn. Kris Konigsfeld UUCP: {ihnp4,seismo,pur-ee,convex}!uiucdcs!uicsrd!konigsfe ARPANET: konigsfe%uicsrd@a.cs.uiuc.edu CSNET: konigsfe%uicsrd@uiuc.csnet BITNET: konigsfe@uicsrd.csrd.uiuc.edu