how does this work
but out put is i =3 and j =4;Code:main() { int i=3; int j; j = sizeof(++i+ ++i); // ++i = 4, again ++i = 5. Then ++i + ++i = 5+5 = 10? printf("i=%d j=%d", i ,j); }
This is a discussion on Help with increment operator within the C Programming forums, part of the General Programming Boards category; how does this work Code: main() { int i=3; int j; j = sizeof(++i+ ++i); // ++i = 4, again ...
how does this work
but out put is i =3 and j =4;Code:main() { int i=3; int j; j = sizeof(++i+ ++i); // ++i = 4, again ++i = 5. Then ++i + ++i = 5+5 = 10? printf("i=%d j=%d", i ,j); }
Last edited by capvirgo; 02-18-2008 at 10:47 AM.
Okay, I was about to quote concerning evaluation order, but in this case it does not matter.
The answer is that sizeof does not evaluate its operand, so what you are seeing is equivalent to sizeof(int), which in this case is 4.
C + C++ Compiler: MinGW port of GCC
Version Control System: Bazaar
Look up a C++ Reference and learn How To Ask Questions The Smart Way
i think that the pre increment or post does not vary w.r.t to i and the j depends on size of operator