News for hackers. Stuff that matters.
Re:Dennis Ritchie on the priorities of && || vs. == etc. (1982) by BenjiWiebe on Friday January 05, 2024 @07:08PM (#38886824)
That's just the way C is. If you want to check "truthiness" (as much as you can in C), just do 'if x'.
Re:Dennis Ritchie on the priorities of && || vs. == etc. (1982) by trealira on Saturday January 06, 2024 @03:18AM (#38889579)
Something nice in C is that "if (x)" is always equivalent to "if (x != 0)". NULL is a macro for 0, and so is false. Boolean expressions evaluate to 0 if they don't hold. This isn't true in C++, though.