自己写了一个字符串复制函数:
1 #include<stdio.h> 2 #include<assert.h> 3 char *mystrcpy(char *des,char *ser) 4 { 5 assert((des!=NULL)&&(ser!=NULL)); 6 char *adress=des; 7 int num=0; 8 while(*ser!='\0') 9 { 10 *des++=*ser++; 11 num++; 12 } 13 printf("data:%d\n",num); 14 return adress; 15 } 16 int main() 17 { 18 char a[]="hello qiuheng\n"; 19 char b[16]="aaaaa"; 20 int *e=NULL; 21 char *p,*q; 22 p=a; 23 q=b; 24 mystrcpy(q,p); 25 printf("character:%s",q); 26 //printf("num:%d\n",e); 27 return 0; 28 }