Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site umcp-cs.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!umcp-cs!chris From: chris@umcp-cs.UUCP (Chris Torek) Newsgroups: net.lang.c Subject: Re: c programming style Message-ID: <870@umcp-cs.UUCP> Date: Tue, 16-Jul-85 00:13:25 EDT Article-I.D.: umcp-cs.870 Posted: Tue Jul 16 00:13:25 1985 Date-Received: Thu, 18-Jul-85 03:45:18 EDT References: <11570@brl-tgr.ARPA> <935@teddy.UUCP> Organization: U of Maryland, Computer Science Dept., College Park, MD Lines: 24 > 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: > argv++; > This will get us to the next pointer.... > argv = argv + 1; > will NOT (unless by the happy happinstance that a pointer is exactly > the same size as a character!) Nope. In this case ``argv = argv + 1'' will get you to the next pointer, just like ``argv++''. See any C book, ``pointer arithmetic''. The form ``lvalue += 1'' is always equivalent to ``++lvalue'' (though many compilers will generate different code for the two). Furthermore, ``lvalue++'' is equivalent to ``++lvalue'' iff the value of the expression is not used. (Again, some compilers---not many---may generate different code.) -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@maryland