Path: utzoo!mnetor!uunet!husc6!think!bloom-beacon!mit-eddie!uw-beaver!cornell!rochester!PT.CS.CMU.EDU!IUS1.CS.CMU.EDU!edw From: edw@IUS1.CS.CMU.EDU (Eddie Wyatt) Newsgroups: comp.lang.c Subject: Re: Associativity -- what is it? Message-ID: <933@PT.CS.CMU.EDU> Date: 23 Feb 88 03:16:46 GMT References: <226@mccc.UUCP> <224@sdrc.UUCP> <234@mccc.UUCP> Sender: netnews@PT.CS.CMU.EDU Organization: Carnegie-Mellon University, CS/RI Lines: 52 > > Well, that still leaves me confused. If i has the value 7, it is 7 that > is added to 3, so it seems to be that the ++ *is* deferred until later. > Also, ++ has higher precedence than +, so why is the incrementation > delayed until after the current value of i is used? > > I think we're getting close, though. :-) Thanks for the help. This really doesn't need a net rely, but .... You're having a problem understanding the semantic behind the post increment instruction. Think of it this way. a = 9 * i++; is equivalent to a = 9 * f(&i); int f(x) int *x; { int y; y = *x; *x = *x + 1; return(y); } and a = 9 * ++i; is equivalent to a = 9 * g(&i); int g(x) int *x; { int y; *x = *x + 1; y = *x; return(y); } Note that i++ evaluates (returns) the value of i before incrementing and ++i evaluates (returns) the value of i after incrementing, that's all. -- Eddie Wyatt e-mail: edw@ius1.cs.cmu.edu