Message from C, C++ discussions

December 2019

— Exactly but isn't it more logically if that worked for the if block? the condition is true so don't execute the else?

Message permanent page

— 

Not sure what you mean.
You can think of it as adding != 0 to the end.
so if (i) the same as if (i != 0).
And in C++ at least it usually highly recommended to use the second form (if it's not a bool operator call that is intended) as it's more clear.

— So the condition is true when it's not equal to 0, instead for a function like strcmp it's true when it's equal to 0

Message permanent page

— Don't know, I find it a bit confusing

— Thank you Pavel

— No, it is the same for strcmp

— It true when it's not zero, and false if it is zero

— If the strings matches (true) it will return 0

— Why true?
strcmp doesn't return true or false, it returns int

— 0 if equal, not zero if not equal

— Alright so I associated that zero meant true

— That's why I was confused I think