#include <iostream>
using namespace std;
void* mymemcpy(void * out_pdst,void * in_psrc,int in_ilen)
{
char* pdest = (char*)out_pdst;
char* psrc = (char*)in_psrc;
if (in_ilen == 0)
{
return out_pdst;
}
if (pdest>psrc && pdest<psrc+in_ilen) //考虑内存地址有重复区域时
{
for (size_t i= in_ilen-1;i !=-1;i--)
{
pdest[i] = psrc[i];
}
cout<<"The dest point is large than src"<<endl;
}
else
{
for (size_t i = 0;i <in_ilen;i++)
{
*pdest++ = *psrc++;
cout<<"The size_t is "<<*pdest<<endl;
}
cout<<"The dest point is less than src"<<endl;
}
return out_pdst;
}
int main()
{
char str[] = "0123456789";
char desk[sizeof(str)] = {0};
mymemcpy(desk,str,strlen(str));
//mymemcpy(str+1,str+0,strlen(str)-1);
//cout<<"after process the str is "<<str<<endl;
cout<<"after process the desc is "<<desk<<endl;
system("Pause");
return 0;
}