memcmp

Compares two objects, byte by byte. The compare operation starts with the first byte in each object.

Format

#include  <string.h>

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

Arguments

s1
A pointer to the first object.
s2
A pointer to the second object.
size
The length of the objects to be compared.

If size is zero, the two objects are considered equal.

Description

This function uses native byte comparison. The sign of the value returned is determined by the sign of the difference between the values of the first pair of unlike bytes in the objects being compared. Unlike the strcmp function, the memcmp function does not stop when a null character is encountered.

Return Value
An integer less than, equal to, or greater than 0, depending on whether the lexical value of the first object is less than, equal to, or greater than that of the second object. 


Previous Page | Next Page | Table of Contents | Index