Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: notesfiles Path: utzoo!linus!vaxine!wjh12!genrad!decvax!harpo!seismo!hao!hplabs!hp-pcd!hpcnob!barrett From: barrett@hpcnob.UUCP Newsgroups: net.lang.c Subject: Re: pointer question Message-ID: <4900002@hpcnob.UUCP> Date: Mon, 9-Apr-84 12:57:00 EST Article-I.D.: hpcnob.4900002 Posted: Mon Apr 9 12:57:00 1984 Date-Received: Sat, 14-Apr-84 09:22:29 EST References: <7624@mgweed.UUCP> Organization: Hewlett-Packard Colorado Networks Operation - Fort Collins, CO Lines: 18 Nf-ID: #R:mgweed:-762400:hpcnob:4900002:000:945 Nf-From: hpcnob!barrett Apr 10 09:57:00 1984 How is p = p + 4 not portable when p is a pointer? From K & R p 188: The result of the + operator is the sum of the operands. A pointer to an object in an array and a value of any integral type may be added. The latter is in all cases converted to an address offset by multiplying it by the length of the object to which the pointer points. The result is a pointer of the same type as the original pointer, and which points to another object in the same array, appropriately offset from the original object. Thus if P is a pointer to an object in an array, the expression P+1 is a pointer to the next object in the array. No further type combinations are allowed for pointers. It would seem that this is non-portable only if used as something other than an index into the original storage area of the pointer. Do you have an example of another case? Dave Barrett (hplabs!hp-dcd!barrett)