Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

memcmp - Compare memory areas

&pagelevel(4)&pagelevel

Definition

#include <string.h>

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

memcmp compares the contents of the first n bytes of the memory areas to which s1 and s2
point.

Return val.

< 0

In the first n bytes, the contents of s1 are lexically smaller than the contents
of s2.

0

In the first n bytes, the contents of s1 and s2 are of equal lexical size (i.e.
identical).

> 0

In the first n bytes, the contents of s1 are lexically larger than the contents
of s2.

Note

This function is suitable for processing character arrays containing the null byte (\0), since
memcmp does not interpret the null byte as the ’end of text’.

See also

memchr, memcpy, memset