Could someone explain me why this short line of code is returning 1?
int i = 0;
if(i++) i++;
printf("%d", i);
I mean when checking the if statement i
has to be incremented otherwise the result would not be 1. But then as it is incremented is should be incremented once again resulting in 2.
And even better, why this line of code is resulting 2?
int i = 0;
if(++i || i++) i++;
Also this
int i = 0;
if(++i && i++) i++;
Returns 3.
Aucun commentaire:
Enregistrer un commentaire