C Programming Increment and Decement Operaotr Proble -


$void main() { int a=10,c; c= ++a + ++a; printf("%d",c); } 

this program actuly print valu of c=24 calculation can should c=23 ,how possible

your program has bug -- modify same variable twice without intervening sequence point. fix bug , mystery go away.

a deep understanding of not how language works how compilers work required understand why buggy code happens happens do. suggest not writing buggy code and, when find bug, fix instead of trying understand precisely why , how broke.

my advice stop. learned right lesson -- code triggers undefined behavior unpredictable , doesn't might expect do. that's need know ub until you're expert @ using language correctly.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -