Twisted C++ code -


possible duplicate: undefined behavior , sequence points

 #include< iostream.h>  int main()  {        int i=7,j=i;        j=(i++,++i,j++*i);        cout <<j;        return 0;  } 

what output of c++ code?

it's homework professor gave me.

it helps convince people don't believe undefined compiling program several compilers , observing results:

after fixing iostream.h error,

  • g++ 4.5.2 prints 64
  • clang++ 2.8 prints 63
  • sun c++ 5.8 prints 63
  • msvc 2010 prints 64

(oh, and, re-written use c i/o, original k&r c compiler on unix 7 prints 63)


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -