#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
void my_memcpy(void* des,const void* src,size_t k)
{
while (k--)
{
*(char*)des = *(char*)src;
++(char*)src;
++(char*)des;
}
}
void* my_memmove(void* des, void* src,size_t count)
{
const char* p = src;
if (src > des)
{
while (count--)
{
*(char*)des = *(char*)src;
++(char*)src;
++(char*)des;
}
}
else
{
while (count--)
{
*((char*)des + count) = *((char*)src + count); //倒序交换,count从19开始
}
}
return p;
}
int main()
{
int arr1[] = { 1,2,3,4,5,6,7,8,9,10 };
int arr2[10] = { 0 };
//my_memcpy(arr2, arr1, sizeof(arr1));
void* ret = my_memmove(arr1+2, arr1,20);
for(int i =0;i<10;printf("%d ",arr1[i++]));
return 0;
}
标签:count,src,memmove,void,des,笔记,char,arr1,memcpy From: https://www.cnblogs.com/godex/p/16622750.html