mercredi 22 mai 2019

Why does this if statement return true

I've been thinking of some beginner mistakes and I ended up with the one on the if statement. I expanded a bit the code to this:

if (i = 1 && i == 0) {
    cout << i;
}

what I have seen is that the if statement returns true and it cout's i as 1. If i is 1 why the boolean expression returned true?

Aucun commentaire:

Enregistrer un commentaire