Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/5/84; site othervax.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!cmcl2!philabs!micomvax!othervax!scott From: scott@othervax.UUCP (Scott Pace) Newsgroups: net.lang.c Subject: Re: c programming style Message-ID: <427@othervax.UUCP> Date: Wed, 17-Jul-85 11:37:07 EDT Article-I.D.: othervax.427 Posted: Wed Jul 17 11:37:07 1985 Date-Received: Sat, 20-Jul-85 09:15:17 EDT References: <11570@brl-tgr.ARPA> <935@teddy.UUCP> Reply-To: scott@othervax.UUCP (Scott Pace) Organization: Philips Information Systems - St. Laurent P.Q., Canada Lines: 69 In article <935@teddy.UUCP> rdp@teddy.UUCP (Richard D. Pierce) writes: > >One of the points with the C i++ versus i = i = 1 issue is the one of >pointers (although some alluded to it). > >Say we have some item like: > > > main(argc, argv) > int argc; > char **argv; > >stepping through the array of pointers can be done by by incrementing >a pointer: > > while (condition) /* or some other loop construct */ > . . . > > argv++; > >This will get us to the next pointer, whereas, > > argv = argv + 1; > >will NOT (unless by the happy happinstance that a pointer is exactly >the same size as a character!) > >The only equivalent "clear" statement would be: > > argv = argv + sizeof(char *); ! > BULLSHIT!!! Turn to page 96 of K&R. Quoted without permission: "5.4 Address Arithmetic If p is a pointer, then p++ increments p to point to the next element of WHATEVER kind of object p points to, AND p+=i increments p to point i elements beyond where it currently does." So if we say i has the value 1; p++ ++p p+=i and since p+=i is equivalent to p = p + i all four forms have EXACLTY the same effect on p. And in our case: ++argv argv++ argv+=1 argv=argv+1 are ALL EQUIVALENT!!! Read the book next time. Scott Pace, Philips Info. Sys. Ltd., Montreal, Canada philabs!micomvax!othervax!scott