3 ms·
strcmp,memcmp,etc. return 0 for equality, maybe you'd count that? But it's not really indicating "true", more "no difference". main() returns 0 for success, bu
by jstanley 5y ago
strcmp,memcmp,etc. return 0 for equality, maybe you'd count that? But it's not really indicating "true", more "no difference".
main() returns 0 for success, but I expect that is owed more to Unix.
A lot of (e.g. Linux) system calls return 0 for success and an error value on error, but again that's more down to Unix than C.
- riverlong 5y agoI wouldn't count strcmp, etc. It returns < 0 if str1 is shorter and > 0 if str1 is longer. Returning 0 means there is 0 difference. That's not a True/False. "0" is not a "truthy" exit code for a system call, it rather denotes the absence of an error. In my view, a value X being "truthy" means that `bool(X)` evaluates to TRUE, or `if(X)` gets executed.