1. ## !memcmp in set

Good afternoon. I've already read the doc for memcmp still I don't understand why in this function:

Code:
```static int match_int(const void *key1, const void *key2) {

/*****************************************************************************
*                                                                            *
*  Determine whether two integers match.                                     *
*                                                                            *
*****************************************************************************/

return !memcmp(key1, key2, sizeof (int));

}```
memcmp has a logical negation operator instead of being written:

Code:
```
return memcmp(key1, key2, sizeof(int));```
for a function of a set like this:

Code:
```
int set_is_member(const Set *set, const void *data) {

ListElmt *member;

/*****************************************************************************
*                                                                            *
*  Determine if the data is a member of the set.                             *
*                                                                            *
*****************************************************************************/

for (member = list_head(set); member != NULL; member = list_next(member)) {

if (set->match(data, list_data(member)))
return 1;

}

return 0;

}```

2. Originally Posted by thames
Good afternoon. I've already read the doc for memcmp still I don't understand why in this function:

Code:
`     return !memcmp(key1, key2, sizeof (int));`
memcmp returns 0 exactly when key1 and key2 are equal. Therefore !memcmp reverses the meaning, returning nonzero when they are equal. It is equivalent to writing

Code:
```bool is_equal = (memcmp(key1, key2, sizeof(int)) != 0);
return is_equal;```

3. Well memcmp returns 0 when both things match.

So the use of ! is to make the function return 1 (aka true) when things match, as opposed to 0.

You could also write with the same effect
return memcmp(key1, key2, sizeof (int)) == 0;