*p++ = *p results?
Doug Gwyn
gwyn at brl-smoke.ARPA
Mon Mar 24 16:12:59 AEST 1986
In article <312 at imagen.UUCP> kevin at imagen.UUCP (Kevin L. Malloy) writes:
>In the statement *p++ = *p; what will be the result? Will p be equal
>to itself or will p be equal to the next value it is pointing to?
>In other words should p be incremented after it is evaluated or should
>p be incremented after the assignment operation is finished?--
Obviously `p' equals itself! I will assume you mean "does `p'
point to the next value after the one `p' initially pointed to?"
The technically correct answer is, `p' must be incremented
by the time the next "sequence point" (defined by X3J11) is
reached. My copy of the draft standard is not at hand at the
moment, but I believe there is no sequence point until after
the assignment. That would mean that either result is legal;
in other words, don't write code like this.
More information about the Comp.lang.c
mailing list