Page 1 of 1

Please Help Me...

Posted: Wed Mar 15, 2006 8:56 am
by Timo
I have a code like this :

Code: Select all


#include <stdio.h>

int main()
{
  int x,y;
   
  x=4;
  y=x++ * ++x;
  x=4;
  printf("%d %d\n",y,  x++ * ++x);

  return 0;
}

I think the result will be :
25 25

but when I test :
25 24

please explain to me ?

Re: Please Help Me...

Posted: Wed Mar 15, 2006 9:20 am
by sumankar
Timo wrote:I have a code like this :

Code: Select all

[...]
  y=x++ * ++x;
  x=4;
  printf("%d %d\n",y,  x++ * ++x);
The nadir of Undefined Behaviour!
Multiple ambiguous side-effects within a single sequence point. For more:
http://c-faq.com/expr/evalorder2.html