#include
#include
using namespace std;
void *mymemcpy(void *des,const void * src , int size)
{
char *d = (char*)des;
char *s = (char*)src;
if(d < s)
while(size--)
*d++ = *s++;
else
{
d += size-1;
s += size-1;
while(size--)
*d-- = *s--;
/*
d += size;
s += size;
while(size--)
*--d = *--s;
*/
}
return d;
}
int main()
{
cout << "Hello world!" << endl;
char src[] = "abcdefg";
char *des = (char*)malloc(strlen(src)); //包括'\0'
mymemcpy((void *)des,(void *)src,3);
cout<
cout<
return 0;
}
阅读(1136) | 评论(0) | 转发(0) |