3 ms·
In C, comparing boolean-like variables to true and false constants is bad practice. The comp.lang.c FAQ touches upon this: http://c-faq.com/bool/bool2.html ht
by kazinator 7y ago
In C, comparing boolean-like variables to true and false constants is bad practice.
The comp.lang.c FAQ touches upon this:
http://c-faq.com/bool/bool2.html http://c-faq.com/bool/bool2.html
- mar77i 7y agoI find myself both agreeing and disagreeing here. I put comparators compulsively everywhere, especially because I switch between multiple languages, but I also don't trust my memory and keep a close eye on the documentation, therefore I usually end up with if (isupper(c) != 0)
- kazinator 7y agoThe real tripper-upper with isupper (and siblings) is that the argument is of type int and must have values in the range 0 to UCHAR_MAX (those of unsigned char) or else EOF. Anything else is undefined behavior.
- enriquto 7y agoif (isupper(c) != 0) This code is illegible to me. How do you read it aloud? "if c is upper is not zero" ? It makes no sense. Compare it with the normal way of writing "if(isupper(c))" which is pronounced "if c is upper", which is perfectly clear, grammatical English.