Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site bbncca.ARPA Path: utzoo!linus!bbncca!keesan From: keesan@bbncca.ARPA (Morris Keesan) Newsgroups: net.lang.c Subject: Re: & operator Message-ID: <395@bbncca.ARPA> Date: Fri, 16-Dec-83 09:56:38 EST Article-I.D.: bbncca.395 Posted: Fri Dec 16 09:56:38 1983 Date-Received: Sat, 17-Dec-83 03:24:48 EST References: <1974@fortune.UUCP> Organization: Bolt, Beranek and Newman, Cambridge, Ma. Lines: 25 ------------------------------- Dave Olson (fortune!olson) says: >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. I would have to disagree. Extending the parenthesization one step further, we get the following three equivalent statements: out = &*in++; out = &(*in++); out = &(*(in++)); /* ++ and unary * and & group right to left */ (in++) is the value of 'in' BEFORE it is incremented. Once this value is evaluated, 'in' can be incremented, but its new value has no effect on the further evaluation of the expression. Then (*(in++)) is the object pointed to by 'in' before incrementation, and &(*(in++)), or (&*in++), is its address, which is of course the original value of 'in', which is 'buf', not 'buf+1'. -- Morris M. Keesan {decvax,linus,wjh12}!bbncca!keesan keesan @ BBN-UNIX.ARPA