HP C/iX Library Reference Manual (30026-90004)

Chapter 5 255
HP C/iX Library Function Descriptions
memcmp
memcmp
Compares the first
n
characters of two objects.
Syntax
#include <string.h>
int memcmp(const void *
s1
, const void *
s2
, size_t
n
);
Parameters
s1
A pointer to the first object.
s2
A pointer to the second object.
n
The number of characters to compare.
Return Values
<0
s1
is less than
s2
.
0
s1
is equal to
s2
.
>0
s1
is greater than
s2
.
Description
The memcmp function compares the first
n
characters of the object pointed to by
s1
to the
first
n
bytes of the object pointed to by
s2
. The result is returned as an integer. Null
characters in the objects do not cause this comparison function to stop.
The contents of "holes" used as padding for alignment with structure objects are
indeterminate. Strings shorter than their allocated space and unions can also cause
comparison problems.
See Also
memccpy(), memchr(), memmove(), memset(), strcmp(), strcoll(), strxfrm(), ANSI C
4.11.4.1