 |
C251 User's Guide |
 |
|
|
|
|
memcmp
| Summary |
|
| Description |
The memcmp function compares the first len bytes from buf1 and buf2 and returns a value indicating their relationship as
follows:
| Value |
Description |
| < 0 |
buf1 less than buf2 |
| = 0 |
buf1 equal to buf2 |
| > 0 |
buf1 greater than buf2 |
|
| Return Value |
The memcmp function returns a positive, negative, or zero
value indicating the relationship of buf1 and
buf2.
|
| See Also | memccpy, memchr, memcpy, memmove, memset |
| Example |
#include <string.h>
#include <stdio.h> /* for printf */
void tst_memcmp (void) {
char hexchars [] = "0123456789ABCDEF";
char hexchars2 [] = "0123456789abcdef";
char i;
i = memcmp (hexchars, hexchars2, 16);
if (i < 0)
printf ("hexchars < hexchars2\n");
else if (i > 0)
printf ("hexchars > hexchars2\n");
else
printf ("hexchars == hexchars2\n");
}
|
|
|
|