标签:
void * memcpy(void * dst, const void * src, size_t count) { void *res=dst; while (count--) { *(char*)dst = *(char*)src; dst = (char*)dst + 1; src = (char*)src + 1; } return res; }
void * memmove(void * dst, const void * src, size_t count) { void *res = dst; //重叠部分不影响或者不存在重叠 if (dst <= src || (char*)src + count <= (char*)dst) { while (count--) { *(char*)dst = *(char*)src; dst = (char*)dst + 1; src = (char*)src + 1; } } else { dst = (char*)dst + count - 1; src = (char*)src + count - 1; while (count--) { *(char*)dst = *(char*)src; dst = (char*)dst - 1; src = (char*)src - 1; } } return res; }
void* memset(void* dst, int val, size_t count) { void* res = dst; while (count--) { *(char*)dst = (char)val; dst = (char*dst) + 1; } return res; }
标签:
原文地址:http://www.cnblogs.com/jason1990/p/4663820.html