15 lines
264 B
C
15 lines
264 B
C
|
|
#include <stddef.h>
|
||
|
|
|
||
|
|
int memcmp(const void *a, const void *b, size_t n)
|
||
|
|
{
|
||
|
|
const unsigned char *s1 = a, *s2 = b;
|
||
|
|
|
||
|
|
for (size_t i = 0; i < n; i++) {
|
||
|
|
if (s1[i] != s2[i]) {
|
||
|
|
return ((s1[i] < s2[i]) ? -1 : 1);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return 0;
|
||
|
|
}
|