关于C函数的实现

一些关于c函数的实现,后面慢慢补…

1.memcpy函数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
void memcpy(void*psrc,void*pdst,size_t length)
{
if(psrc == NULL || pdst == NULL)
return;

char*d = NULL;
char*s = NULL;

if(pdst > psrc + length || pdst < psrc)
{
d=(char*)pdst;
s=(char*)psrc;
while(length--)
*d++=*s++;
}
else
{
d=(char*)(pdst + length - 1);
s=(char*)(psrc + length - 1);
while(length--)
*d--=*s--;
}

return;
}

2.strstr函数

3.strcat函数

4.