memcmp

 

Description

Compares characters between two buffers.

Syntax

int memcmp( LPCVOID lpMem1, LPCVOID lpMem2, size_t uSize )

Parameters

lpMem1
[input] First buffer
lpMem2
[input] Second buffer
uSize
[input] Number of characters to compare.

Return

Returns an integer < 0 if lpMem1 is less than lpMem2, returns 0 if lpMem1 is identical to lpMem2, and returns an integer > 0 if lpMem1 greater than lpMem2.

Examples

EX1

void memcmp_ex1()
{
    char    szFirst[] = "1234567890";
    char    szSecond[] = "1234567891";
    size_t  nNumerOfBytesToCompare = 9;  // change this to 10 to see a different result
    int     nResult = memcmp(szFirst, szSecond, nNumerOfBytesToCompare);
    if (0 == nResult)
        out_str("Equal");
    else if (0 > nResult)
        out_str("First is less than second");
    else
        out_str("First is greater than second");
}

Remark

See Also

strcmp

header to Include

origin.h

Reference