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

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