home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 1.ddi / CLIBSRC1.ZIP / MEMICMP.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  1.5 KB  |  56 lines

  1. /*-----------------------------------------------------------------------*
  2.  * filename - memicmp.c
  3.  *
  4.  * function(s)
  5.  *        memicmp - compares two memory areas
  6.  *-----------------------------------------------------------------------*/
  7.  
  8. /*
  9.  *      C/C++ Run Time Library - Version 5.0
  10.  *
  11.  *      Copyright (c) 1987, 1992 by Borland International
  12.  *      All Rights Reserved.
  13.  *
  14.  */
  15.  
  16.  
  17. #include <mem.h>
  18. #include <ctype.h>
  19.  
  20. /*------------------------------------------------------------------------*
  21.  
  22. Name            memicmp - compares two memory areas
  23.  
  24. Usage           int memicmp(const void *s1, const void *s2, size_t n);
  25.  
  26. Prototype in    mem.h & string.h
  27.  
  28. Description     memicmp compares the  first n bytes of s1  and s2, ignoring
  29.                 character case (upper or lower).
  30.  
  31. Return value    < 0     if s1 is less than s2
  32.                 = 0     if s1 is the same as s2
  33.                 > 0     if s1 is greater than s2
  34.  
  35. *---------------------------------------------------------------------------*/
  36.  
  37. #undef toupper
  38.  
  39. #if defined(__FARFUNCS__)
  40. #include <_farfunc.h>
  41. #endif
  42.  
  43. int _FARFUNC memicmp(const void *s1, const void *s2, size_t n)
  44. {
  45.         int dif;
  46.  
  47.         for (; n-- >0; ((unsigned char *)s1)++, ((unsigned char *)s2)++ )
  48.         {
  49.                 dif = toupper(*(unsigned char *)s1) - toupper(*(unsigned char *)s2);
  50.                 if (dif != 0)
  51.                         return(dif);
  52.         }
  53.         return(0);
  54. }
  55.  
  56.