memcmp

Syntax

int memcmp(void *mem1, void *mem2, int n)

Arguments

mem1
The first memory block to compare
mem2
The second memory block, to be compared with mem1
n
The size (in bytes) of the memory blocks to compare

Return

Returns 0 if the two memory blocks are identical. Otherwise, it returns a negative or positive integer depending on whether the value of the data in mem1 is found to be "less than" or "greater than" the value of the data in mem2.

Description

memcmp performs a byte-wise comparison of two memory blocks, to determine if they contain exactly the same data.

Example

Also see

strncmp, strcmp

Comments

Everyone can add his comments about his experiences with this function here. Tips for using it are welcome, too.