Possible Duplicate:
FAQ : Undefined Behavior and Sequence Points
#include<iostream>
#include<stdio.h>   
int main(){
   int myVal = 0;
   printf("%d %d %d\n", ++myVal,myVal,++myVal);
   myVal = 0 ; /*reset*/      
   std::cout<<++myVal<<" "<<myVal<<" "<<++myVal<<std::endl;
   return 0;
}
I got the output 2 2 2 in both the cases. How could it be 2 2 2? I expected 2 1 1 or 1 1 2
 
     
    