*p++ = *p results?

Joseph S. D. Yao jsdy at hadron.UUCP
Thu Mar 27 15:40:31 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?

This kind of thing is specifically defined to be undefined.  Whenever
you have an incremented or decremented variable used elsewhere in the
same expression, the code may be interpreted either way.  If the same
variable is incremented (or decremented) more than once, the code may
be interpreted in any consistent way.
	i = 0;
	printf("%d %d %d %d %d %d\n", i++, i--, i++, i--, i++, i--);
-- 

	Joe Yao		hadron!jsdy at seismo.{CSS.GOV,ARPA,UUCP}



More information about the Comp.lang.c mailing list