Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site utcsstat.UUCP Path: utzoo!utcsstat!cobb From: cobb@utcsstat.UUCP () Newsgroups: net.lang.c Subject: Re: pointer question Message-ID: <1836@utcsstat.UUCP> Date: Mon, 9-Apr-84 00:50:41 EST Article-I.D.: utcsstat.1836 Posted: Mon Apr 9 00:50:41 1984 Date-Received: Mon, 9-Apr-84 01:40:49 EST References: <7624@mgweed.UUCP> <937@inuxc.UUCP>, <155@hercules.UUCP> Organization: U. of Toronto, Canada Lines: 35 If anyone out there is still not convinced about "p = p + 4" portability, after reading Archie's explanation (Archie Lachner), I submit the following: given a structure struct X { int a; int b; int c; } with a register pointer p of type X; p = p + 4 generates addl $48,reg_n,reg_n ; add decimal 48 to register ; VAX - berkeley C compiler and add $30,reg_n ; add octal 30 (24) to register ; 11/70 - Bell C Compiler As you might've guessed, reg_n is p. In each case, the actual value added is * 4. Thus, any fears about "p = p + n" is quite unfounded. In fact, K&R states that a construct p[i] is actually treated as p + i. If this is still not convincing enough, c'est la vie !! OZ Ozan S. Yigit (utzoo!utcsstat!cobb) (utzoo!yetti!ozan) Dept. of Computer Science York University