Chapter Contents

Previous

Next
memcasecmp

memcasecmp



Compare Two Blocks of Memory, ignoring differences in case

Portability: SASC


SYNOPSIS
DESCRIPTION
RETURN VALUE
IMPLEMENTATION
EXAMPLE
RELATED FUNCTIONS
SEE ALSO


SYNOPSIS

#include <lcstring.h>

int memcasecmp( const void *ptr1, const void *ptr2, size_t n );


DESCRIPTION

memcasecmp compares, while ignoring differences in case, two blocks of memory specified by ptr1 and ptr2. The number of bytes to be compared is n. The null character is treated like any other character and participates in the comparison. The comparison is performed using the standard EBCDIC collating sequence with the exception that differences in case are ignored. Note that case differences are determined in a locale- specific manner.


RETURN VALUE

memcasecmp returns 0 if the two blocks are equal, an integer less than 0 if the first block is less than the second, or an integer greater than 0 if the first block is greater than the second.


IMPLEMENTATION

memcasecmp is functionally equivalent to memcmp, except that each byte is converted to lowercase before the comparison is made.


EXAMPLE

#include <lcstring.h>

int main(void)
{
   int ch;
   int num;
   char lwr_alpha[] = "abcdefghijklmnopqrstuvwxyz";
   char upr_alpha[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
   char mix_alpha[] = "AbCdEfGhIjKlMnOpQrStUvWxYz";

   for (num = 1; num <= strlen(lwr_alpha); num++)
   {
     ch = memcasecmp(lwr_alpha, mix_alpha, num);
     if ( ch != 0 )
     {
        exit(EXIT_FAILURE);
     }
   }
   for (num = 1; num <= strlen(upr_alpha); num++)
   {
     ch = memcasecmp(upr_alpha, mix_alpha, num);
     if ( ch != 0 )
     {
        exit(EXIT_FAILURE);
     }
   }
   exit(EXIT_SUCCESS);
}


RELATED FUNCTIONS

memcmp, strcasecmp, strcmp, strncasecmp, strncmp


SEE ALSO

"String Utility Functions" in Chapter 2, "Function Categories."


Chapter Contents

Previous

Next

Top of Page

Copyright © 2004 by SAS Institute Inc., Cary, NC, USA. All rights reserved.