C Programming Increment and Decement Operaotr Proble -
this question has answer here:
- why these constructs (using ++) undefined behavior? 12 answers
- undefined behavior , sequence points 4 answers
$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
Post a Comment