memicmp()

Updated: April 19, 2023

Compare two buffers, ignoring case

Synopsis:

#include <string.h>

int memicmp( const void* s1,
             const void* s2,
             size_t length );

Arguments:

s1, s2
Pointers to the buffers that you want to compare.
length
The number of bytes that you want to compare.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The memicmp() function compares (case insensitive) length bytes of the buffer pointed to by s1 with those of the buffer pointed to by s2.

Returns:

0
The object pointed to by s1 is the same as the object pointed to by s2.
Less than 0
The object pointed to by s1 is less than the object pointed to by s2.
Greater than 0
The object pointed to by s1 is greater than the object pointed to by s2.
Note: The memicmp() function returns the difference between the original characters. The QNX 4 version of memicmp() returned the difference between the lowercase version of the characters.

Examples:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main( void )
{
    char buffer[80];
    int retval;

    strcpy( buffer, "World" );

    retval = memicmp( buffer, "hello", 5 );
    if( retval < 0 ) {
        printf( "Less than\n" );
    } else if( retval == 0 ) {
        printf( "Equal\n" );
    } else {
        printf( "Greater than\n");
    }
    
    return EXIT_SUCCESS;
}

produces the output:

Less than

Classification:

QNX Neutrino

Safety:  
Cancellation point No
Interrupt handler Yes
Signal handler Yes
Thread Yes