Message from C, C++ discussions

December 2019

— Alright writing it like this it's better I think

— 

Strcmp returns a value that represents the difference between the first characters encountered that are different in the two strings (0 if there is no difference). It has nothing to do with the logic 0 or false.

— If a function returns an integer rather than a boolean there's usually a reason for it.

— I agree, I'm not a C programmer, but for me this == 0 is a clear sign that you check for strings equality

Message permanent page

— Alright, yeah, got it, thank you all

— Thanks

— No, it is not required to return difference. Implementation which returns only -1, 0 or 1 is perfectly valid

Message permanent page

— Interesting, I didn't know that. But there are still three values, and you can't represent three different values with a boolean.

Message permanent page

— Of course

— It does make some sense though. I assume the non-zero values are mostly used for sorting purposes anyway.

Message permanent page

— Wtf

— Brother this group is for coding enthusiast not for religious opinionz