An interesting question of coding style. In C and C++, some people write the strcmp() function as follows:
if (!strcmp(foo,bar)) {
/* do something interesting */
}
This makes the code hard to read, in my opinion. You are checking a positive result -- in this case, that two strings are equal -- and yet (because C and C++ treat FALSE as zero and a non-zero value as TRUE) you must check a negative result. This is highly non-intuitive, and I think it should be considered bad coding style.
Instead, the code should be written this way:
if (strcmp(foo,bar) == 0) {
/* do something interesting */
}
It's not that much more typing, and it's far clearer as to what the intent of the conditional really is.
But that's just me.
