-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmy_memcpy.c
More file actions
39 lines (39 loc) · 767 Bytes
/
my_memcpy.c
File metadata and controls
39 lines (39 loc) · 767 Bytes
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include<stdio.h>
#include<windows.h>
#include<string.h>
#include<assert.h>
int main()
{
/*char* src = "xzuidiao";
char dst[20] = "0";*/
int src[] = {1,2,3,4,5,6};
int dst[20] = {0};
//int len = strlen(src);
int charnum = sizeof(src);
int i = 0;
char* ret = NULL;
void* my_memcpy(void* src,const void* dst,int charnum);
ret = my_memcpy(src,dst,charnum);
/*printf("DST is %s",ret);*/
for(i=0;i<6;i++)
printf("%d",dst[i]);
system("pause");
return 0;
}
void* my_memcpy(const void* src,void* dst,int charnum)
{
void* ret = dst;
assert(src);
assert(dst);
//#ifndef DEGUG
// if(NULL==dst||NULL==src){
// return dst;
// }
//#endif
while(charnum--){
*(char*)dst = *(char*)src;
src = (char*)src + 1;
dst = (char*)dst + 1;
}
return ret;
}