Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site turtlevax.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!decwrl!turtlevax!ken From: ken@turtlevax.UUCP (Ken Turkowski) Newsgroups: net.lang.c Subject: Re: increment operator Message-ID: <827@turtlevax.UUCP> Date: Mon, 15-Jul-85 14:37:20 EDT Article-I.D.: turtleva.827 Posted: Mon Jul 15 14:37:20 1985 Date-Received: Thu, 18-Jul-85 04:11:46 EDT References: <11536@brl-tgr.ARPA> Reply-To: ken@turtlevax.UUCP (Ken Turkowski) Organization: CADLINC, Inc. @ Menlo Park, CA Lines: 22 Summary: In article <11536@brl-tgr.ARPA> lcc.dan@UCLA-LOCUS.ARPA (Dan McMullen) writes: >consider the operation of incrementing a pointer: > int *ip; > > ip++; > vs. > ip = ip + 1; >this may be a case where the '++' construct is clearer. any comments? > >for myself, the '++' construct in general is more *intuitive* than the altern- >ative. it denotes a *single* operation, whether on an interger or a pointer, >whereas 'i = i + 1' denotes two (or three if fetching the value of 'i' is >included. this is a beneficial economy of thought as i read a program. Also, saying "ip = ip + 1" implies that the pointer is incremented by 1, rather than by one int size, which may be 2 or 4. "ip++" implies "advance to the next element". -- Ken Turkowski @ CADLINC, Menlo Park, CA UUCP: {amd,decwrl,hplabs,nsc,seismo,spar}!turtlevax!ken ARPA: turtlevax!ken@DECWRL.ARPA