& operator - (nf)
andree at uokvax.UUCP
andree at uokvax.UUCP
Mon Dec 19 13:49:49 AEST 1983
#R:iwu1a:-16200:uokvax:3000012:000:840
uokvax!andree Dec 16 09:38:00 1983
/***** uokvax:net.lang.c / fortune!olson / 9:57 pm Dec 14, 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.
(The original article did not include the second line of my example,
and asked whether out should be set to 'in', or 'in+1'. The answer
is of course 'in'. The question is not meaningful as stated. The
question should be: does it point to the ORIGINAL value of 'in', or
the incremented value of 'in'.)
Dave Olson
/* ---------- */
Yes, but the & operator is not being applied to `in', but to `*in', with
the increment happening AFTER the dereference. Therefore, you should get
buf, not buf+1.
<mike
More information about the Comp.lang.c
mailing list