Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site druxy.UUCP Path: utzoo!linus!security!genrad!grkermit!masscomp!clyde!ihnp4!houxm!hogpc!drutx!drux3!druxy!jas From: jas@druxy.UUCP Newsgroups: net.lang.c Subject: Re: & operator in &(*in++). Message-ID: <888@druxy.UUCP> Date: Sat, 17-Dec-83 20:35:05 EST Article-I.D.: druxy.888 Posted: Sat Dec 17 20:35:05 1983 Date-Received: Tue, 20-Dec-83 06:40:55 EST Organization: AT&T Information Systems Laboratories, Denver Lines: 38 Re: I would have to disagree with chris as to what should be assigned by: char *in, *out, buf[]; in = buf; out = &(*in++); since he forgot the parentheses. Given the parentheses, out SHOULD be set buf+1; that is, 'in' is incremented BEFORE the & operator is applied. -- Dave Olson (fortune!olson) Dave, I believe you are mistaken. Perhaps we can finally set this question to rest by explicitly listing the order of operations when evaluating &(*in++): 1. Evaluate 'in'. 2. Increment 'in'. This is a side effect, which does not affect the evaluation of the expression &(*in++). 3. Dereference the value produced by step 1. The result is an lvalue of type char (I am using 'lvalue' as defined by Kernighan and Richie in section 5 of Appendix A of *The C Programming Language*). The value of this result is the character pointed to by 'in' before incrementing, i.e., buf[ 0 ]. 4. Take the address of the value produced by step 3. The result has type 'pointer to char' (or 'char *', if you prefer); its value is &buf[ 0 ], or buf. Step 2 seems to be the only real bone of contention. Section 7.2 of Appendix A of *The C Programming Language* states: "When postfix ++ is applied to an lvalue, the result is *the value of the object referred to by the lvalue*. *After* the result is noted, the object is incremented...." (my emphasis). I see no ambiguity in this sentence. In my opinion, this subject has now been beaten to death, so here's hoping I've just had the last word ( :-) ). -- Jim Shankland ihnp4!druxy!jas