Logical equality in C
- by andrew cooke
[It seems odd this doesn't exist, so apologies in advance if it's a duplicate]
I want to test for logical equality in C. In other words, I want to know whether two values would be equal if both were converted in the normal way associated with logical expressions.
In C99, I think that
(bool)a == (bool)b
gives what I want. Is that correct? What is the normal way of writing this in traditional C?