From: Andrew Crabtree Message-Id: <199706220305.AA066958721@typhoon.rose.hp.com> Subject: Re: Is this the normal behavior? To: edevaldo AT sysnetway DOT com DOT br (Edevaldo) Date: Sat, 21 Jun 1997 20:05:21 PDT Cc: djgpp AT delorie DOT com In-Reply-To: <33ABA2A0.539A@sysnetway.com.br>; from "Edevaldo" at Jun 21, 97 6:45 pm Precedence: bulk > for( i=0; i<4; printf( "%i %i\n", i, i++) ); I can't remember exactly, but I don't think you are allowed to reference i in both places there when you modify its value. Its one of those screwy 'undefined' outcomes in ANSI I believe. > > 1 0 > 2 1 > 3 2 > 4 3 > > Is this the normal behavior? > In C the later arguments are evaluated first? The stack? Assuming you are using a machine that does stack based passing, then function arguments are evaluated and passed from right to left. This is specifically for printf style functions, where the left most argument tells you how many others to expect. So, in this case, gcc passes the value of I onto the stack (the rightmost one), then increments it, then passes the left i onto the stack. There's other gotchas like it. Try i=10 printf("New Value = %d\n",++i + ++i); Andrew