...
The following approach to using a comparison function for this purpose is preferred. By performing an explicit test, any programmer that wishes to modify the equality test can clearly see the implied behavior and convention that is being followed.
Code Block | ||
---|---|---|
| ||
void login(char *usr, char *pw) { User user = find_User(usr); if (strcmp((user->password),pw_given) == 0) { grantAccess(); } denyAccess("Incorrect Password"); } |
...