memcmp() — Compare bytes

Format

#include <string.h>

int memcmp(const void *buf1, const void *buf2, size_t count);

General description

The memcmp() built-in function compares the first count bytes of buf1 and buf2.

The relation is determined by the sign of the difference between the values of the leftmost first pair of bytes that differ. The values depend on EBCDIC encoding. This function is not locale sensitive.

Returned value

Indicates the relationship between buf1 and buf2 as follows:
Value
Meaning
< 0
The contents of the buffer pointed to by buf1 less than the contents of the buffer pointed to by buf2
= 0
The contents of the buffer pointed to by buf1 identical to the contents of the buffer pointed to by buf2
> 0
The contents of the buffer pointed to by buf1 greater than the contents of the buffer pointed to by buf2

Related Information