首页 > 其他 > 详细

自己实现strcpy函数

时间:2017-04-04 12:33:30      阅读:224      评论:0      收藏:0      [点我收藏+]
 1 #include     //printf
 2 #include     //ssert
 3 #include     //malloc
 4 #include     //strlen
 5 
 6 char * sstrcpy(char * strdst, char * strsrc)
 7 {
 8     char *dst = strdst;
 9     assert(strdst!=NULL && strsrc!=NULL);
10     while((*strdst++ = *strsrc++)!= \0)
11         NULL;
12     return dst; //实现链式表达式
13 }
14 
15 //int num = strlen(strcpy(strdst,"hello world"));
16 
17 int main(void)
18 {
19     int num;
20     char *strdst = (char *)malloc(sizeof(char)*100);
21 
22     if(strdst == NULL)
23         return (-1);
24     num = strlen(sstrcpy(strdst,"hello world"));
25     printf("%d\n", num);
26 
27     return 0;
28 }

 

自己实现strcpy函数

原文:http://www.cnblogs.com/eustoma/p/6664643.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!