home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / cprog / actlib12.zip / STRINGS.ZIP / NCOMP.C < prev    next >
Text File  |  1993-01-14  |  838b  |  33 lines

  1. /*  Copyright (C) 1993   Marc Stern  (internet: stern@mble.philips.be)  */
  2.  
  3. #include "strings.h"
  4.  
  5. /***
  6.  *  Function    :  strncomp
  7.  *
  8.  *  Description :  Compare n characters of two strings case-insensitive
  9.  *           All special characters are translated (éèà...)
  10.  *
  11.  *  Parameters  :  in   char  *str1
  12.  *                 in   char  *str2
  13.  *
  14.  *  Return      :  -1 if str1 <  str2
  15.  *            1 if str1 >  str2
  16.  *            0 if str1 == str2
  17.  *
  18.  *  OS/Compiler :  All
  19.  ***/
  20.  
  21. int strncomp( const char *str1, const char *str2, int length )
  22.  
  23. {
  24.   for (; length && *str1 && *str2; length --, str1++, str2++ )
  25.       if ( chcase(*str1, 1) != chcase(*str2, 1) ) break;
  26.  
  27.   if ( ! length ) return 0;
  28.  
  29.   if ( chcase(*str1, 1) <  chcase(*str2, 1) ) return -1;
  30.   if ( chcase(*str1, 1) >  chcase(*str2, 1) ) return  1;
  31.   return 0;
  32. }
  33.