& operator - (nf)

Mark Brader ntt at dciem.UUCP
Sat Dec 17 08:53:05 AEST 1983


	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.
	
No, Chris was right.  The parentheses here have no effect at all.
Parentheses only affect binding, and here the default binding is the same
as what they ask for.  It is analogous to this:
	x = (y++);
Here, x will get the OLD value of y.  And out will get buf, the old value of in.
The value of a variable that has ++ after it does NOT change until after it has
been used.  In this case that means that the old value of in is "passed to" *
and then to () and then to &.

Mark Brader, NTT Systems Inc.



More information about the Comp.lang.c mailing list