increment operator
Ken Turkowski
ken at turtlevax.UUCP
Tue Jul 16 04:37:20 AEST 1985
In article <11536 at brl-tgr.ARPA> lcc.dan at 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 at DECWRL.ARPA
More information about the Comp.lang.c
mailing list