banan-os/libc/string/memcmp.cpp

14 lines
296 B
C++
Raw Normal View History

2022-11-14 00:27:11 +02:00
#include <string.h>
int memcmp(const void* s1, const void* s2, size_t n)
{
const unsigned char* a = static_cast<const unsigned char*>(s1);
const unsigned char* b = static_cast<const unsigned char*>(s2);
for (size_t i = 0; i < n; i++)
if (a[i] != b[i])
return a[i] - b[i];
return 0;
}