1 /* 2 * memcmp.c 3 */ 4 5 #include <string.h> 6 7 int memcmp(const void *s1, const void *s2, size_t n) 8 { 9 const unsigned char *c1 = s1, *c2 = s2; 10 int d = 0; 11 12 while (n--) { 13 d = (int)*c1++ - (int)*c2++; 14 if (d) 15 break; 16 } 17 18 return d; 19 } 20