_memicmp, _fmemicmp

Description

Compare characters in two buffers (case-insensitive).

#include <memory.h> Required only for function declarations  
#include <string.h> Use either STRING.H or MEMORY.H  

int _memicmp( void *buf1, void *buf2, unsigned int count );

int __far _fmemicmp( void __far *buf1, void __far *buf2,
unsigned int count );

buf1 First buffer  
buf2 Second buffer  
count Number of characters  

Remarks

The _memicmp and _fmemicmp functions compare the first count characters of the two buffers buf1 and buf2 byte-by-byte. The comparison is made without regard to the case of letters in the two buffers; that is, uppercase and lowercase letters are considered equivalent. The _memicmp and _fmemicmp functions return a value indicating the relationship of the two buffers, as follows:

Value Meaning

< 0 buf1 less than buf2
= 0 buf1 identical to buf2
> 0 buf1 greater than buf2

The _fmemicmp function is a model-independent (large-model) form of the _memicmp function. It can be called from any point in any program.

Return Value

The _memicmp and _fmemicmp functions return an integer value, as described above.

Compatibility

_memicmp

Standards:UNIX

16-Bit:DOS, QWIN, WIN, WIN DLL

32-Bit:DOS32X

Use _memicmp for compatibility with ANSI naming conventions of non-ANSI functions. Use memicmp and link with OLDNAMES.LIB for UNIX compatibility.

_fmemicmp

Standards:None

16-Bit:DOS, QWIN, WIN, WIN DLL

32-Bit:None

See Also

_memccpy, memchr, memcmp, memcpy, memset, _stricmp, _strnicmp

Example

/* MEMICMP.C: This program uses _memicmp to compare the first

* 29 letters of the strings named first and second without

* regard to the case of the letters.

*/

#include <memory.h>

#include <stdio.h>

#include <string.h>

void main( void )

{

int result;

char first[] = "Those Who Will Not Learn from History";

char second[] = "THOSE WHO WILL NOT LEARN FROM their mistakes";

/* Note that the 29th character is right here ^ */

printf( "Compare '%.29s' to '%.29s'\n", first, second );

result = _memicmp( first, second, 29 );

if( result < 0 )

printf( "First is less than second.\n" );

else if( result == 0 )

printf( "First is equal to second.\n" );

else if( result > 0 )

printf( "First is greater than second.\n" );

}

Output

Compare 'Those Who Will Not Learn from' to 'THOSE WHO WILL NOT LEARN FROM'

First is equal to second.