COHERENT manpages
This page displays the COHERENT manpage for memcmp() [Compare two regions].
List of available manpages
Index
memcmp() -- String Function (libc) Compare two regions #include <string.h> int memcmp(region1, region2, count) char *region1; char *region2; unsigned int count; memcmp() compares region1 with region2 character by character for count characters. If every character in region1 is identical to its corresponding character in region2, then memcmp() returns zero. If it finds that a character in region1 has a numeric value greater than that of the corresponding character in region2, then it returns a number greater than zero. If it finds that a character in region1 has a numeric value less than less that of the corresponding character in region2, then it returns a number less than zero. For example, consider the following code: char region1[13], region2[13]; strcpy(region1, "Hello, world"); strcpy(region2, "Hello, World"); memcmp(region1, region2, 12); memcmp() scans through the two regions of memory, comparing region1[0] with region2[0], and so on, until it finds two corresponding ``slots'' in the arrays whose contents differ. In the above example, this will occur when it compares region1[7] (which contains `w') with region2[7] (which contains `W'). It then compares the two letters to see which stands first in the character table used in this implementation, and returns the appropriate value. memcmp() differs from the string comparison routine strcmp() in a number of ways. First, memcmp() compares regions of memory rather than strings; therefore, it does not stop when it encounters a NUL. Also, you can use memcmp() to compare an int array with a char array, because memcmp() simply compares areas of data. See Also libc, strcmp(), string.h ANSI Standard, §7.11.4.1