memcmp

Compares two memory blocks

#include <memory.h>
long memcmp (
        const void *s1,
        const void *s2,
        size_t n
)

Arguments

s1 Pointer to memory block 1
s2 Pointer to memory block 2
n Maximum number of bytes to compare

Explanation

The first n bytes of the memory blocks pointed to by s1 and s2 are compared and the result is indicated in the return value.

Return Value

The result of the comparison is indicated in the return value as shown below:

Result Return Value
s1<s2 <0
s1=s2 =0
s1>s2 >0

See Also

bcmp()