home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 1.ddi / CLIB1.ZIP / MEMICMP.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-07  |  1.7 KB  |  51 lines

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