home *** CD-ROM | disk | FTP | other *** search
/ PC Extra Super CD 1998 January / PCPLUS131.iso / DJGPP / V2 / DJLSR201.ZIP / src / libc / ansi / string / strncmp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-29  |  357 b   |  18 lines

  1. /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
  2. #include <string.h>
  3.  
  4. int
  5. strncmp(const char *s1, const char *s2, size_t n)
  6. {
  7.  
  8.   if (n == 0)
  9.     return 0;
  10.   do {
  11.     if (*s1 != *s2++)
  12.       return *(unsigned const char *)s1 - *(unsigned const char *)--s2;
  13.     if (*s1++ == 0)
  14.       break;
  15.   } while (--n != 0);
  16.   return 0;
  17. }
  18.