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() function compares the first length characters 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:
#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
Safety: | |
---|---|
Interrupt handler | Yes |
Signal handler | Yes |
Thread | Yes |
memchr(), memcpy(), memicmp(), memset()