- From: Joe Konczal <joe.konczal@nist.gov>
- Date: Wed, 30 Jan 2002 12:08:15 -0500
- To: Jean-Christophe Touvet <jct@EdelWeb.fr>
- CC: "Desrochers, Gary" <Gary.Desrochers@fmr.com>, Manuele Kirsch Pinheiro <Manuele.Kirsch_Pinheiro@inrialpes.fr>, Rob Corell <rcorell@adobe.com>, David Binderman <d.binderman@virgin.net>, www-lib@w3.org
Jean-Christophe Touvet wrote: >>Hmmm... Don't want to get into a long drawn out discussion on this but >>I don't get why you "concluded" that "i = ++i;" is undefined in K&R "C". >>I have the Kernighan an Ritchie book sitting in front of me and it does >>describe what would happen with the expression "x = ++i;" and "x = >>i++;". >> > > And what about "i = i++;" ? > > Would you increment "i" before or after the assignment ? > > -JCT- > > After, of course. But the result would be the same as incrementing it before. There is only one "i" and it gets incremented either way. Try this little program, and let me know if you find any implementation of C where the value of "i" is not one in both cases. #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { int i; i = 0; i = i++; printf("i = 0, i = i++, i => %d\n", i); i = 0; i = ++i; printf("i = 0, i = ++i, i => %d\n", i); exit(0); }
Received on Wednesday, 30 January 2002 12:08:24 UTC