compare a given number of characters in two objects
#include <string.h> int memcmp( const void *s1, const void *s2, size_t length ); int _fmemcmp( const void __far *s1, const void __far *s2, size_t length );
The memcmp() and _fmemcmp() functions compare the first lengthcharacters of the object pointed to by s1 to the object pointed to by s2.
The _fmemcmp() function is a data-model-independent form of the memcmp() function that accepts far pointer arguments. It is most useful in mixed memory model applications.
an integer, with the value given below:
memchr(), memcpy(), memicmp(), memset()
#include <stdio.h> #include <string.h> void main() { char buffer[80]; strcpy( buffer, "World" ); if( memcmp( buffer, "hello", 5 ) < 0 ) { printf( "Less than\n" ); } else { printf( "Equal to or greater than\n"); } }
produces the output:
Less than