Message from C, C++ discussions

December 2019

— Https://www.programiz.com/c-programming/library-function/string.h/strcmp

— 

Yep, it's better not think of strcmp's contract as of are strings equal, better something like compare strings and return relationship

— I needed this clarification I think 😂

— 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.

Message permanent page

— 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