#include extern "C" void *memset(void *dest, int ch, size_t count) { unsigned char c = static_cast(ch); unsigned char *d = (unsigned char *)dest; for (size_t i = 0; i < count; ++i) d[i] = c; return dest; } extern "C" void *memcpy(void *dest, const void *src, size_t count) { unsigned char *d = (unsigned char *)dest; const unsigned char *s = (const unsigned char *)src; for (size_t i = 0; i < count; ++i) d[i] = s[i]; return dest; } extern "C" int strcmp(const char *lhs, const char *rhs) { const unsigned char *l = (const unsigned char *)lhs; const unsigned char *r = (const unsigned char *)rhs; while (*l == *r) { if (*l == 0) return 0; ++l; ++r; } return *l < *r ? -1 : 1; } extern "C" size_t strlen(const char *str) { size_t len = 0; while (str[len] != '\0') ++len; return len; }