+ 2

Is this really an undefined behaviour??

In Gcc Int a=3; printf("%d %d",a++,++a); What is the working logic of printf with Increment/decrement. Or does it really have any simplified way of working. Because executing this line by forming variations Like Including more a++/++a Give output Which i am unable to predict how is it working. Please help with whatever u got on this.

2nd Jan 2020, 7:55 PM
Shubham kumar
Shubham kumar - avatar
3 Respostas
+ 2
Ok thanks ~ swim ~
2nd Jan 2020, 8:01 PM
Shubham kumar
Shubham kumar - avatar
+ 2
It is undefined, because the result is dependent on the compiler. There is no definition in ansi standard c++, so the compiler writers interpret it differently. This is why embedding inc/dec operators is a bad practice.
4th Jan 2020, 7:27 PM
Michele
Michele - avatar
0
~ swim ~ another doubt..... See this☝
2nd Jan 2020, 7:58 PM
Shubham kumar
Shubham kumar - avatar