Everything

memcmp


Memory comparison

[Classification]

Standard library

[Syntax]

#include <string.h>

int memcmp(const void *s1, const void *s2, size_t n);

[Return value]

An integer greater than, equal to, or less than 0 is returned, depending on whether the object indicated by s1 is greater than, equal to, or less than the object indicated by s2.

[Description]

This function compares the first n characters of an object indicated by s1 with the object indicated by s2.

[Example]

#include    <string.h>
int func(const void *s1, const void *s2) {
        int i;
        i = memcmp(s1, s2, 5);  /*Compares the first five characters of the character 
                                  string indicated by s1 with the first five 
                                  characters of the character string indicated by 
                                  s2.*/
        return(i);
}