memcmp.c (271B)
1 #include <string.h> 2 3 int memcmp (const void *str1, const void *str2, int count) { 4 const unsigned char *s1 = str1; 5 const unsigned char *s2 = str2; 6 7 while (count-- > 0) { 8 if (*s1++ != *s2++) { 9 return s1[-1] < s2[-1] ? -1 : 1; 10 } 11 } 12 13 return 0; 14 }