码迷,mamicode.com
首页 > 其他好文 > 详细

实现strcpy函数

时间:2018-10-17 19:03:35      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:des   const   turn   code   span   cat   函数   ==   tac   

 

 

不使用库函数,实现strcpy函数:

1 char *my_strcpy(char *t,char *s){
2     char *strDest=t;
3     if(t==NULL && s==NULL){
4         return NULL;
5     }
6     while((*t++=*s++));
7     return strDest;
8 }

不使用库函数,实现strcat函数:

 1 char *cat_stacat(char *dst, const char *src) {
 2     if (NULL == dst && NULL == src)
 3         return NULL;
 4     
 5     char *addr = dst;
 6 
 7     while (*dst) 
 8         ++dst;
 9 
10     while (*dst++ = *src++) ;
11     
12     *dst = \0; 
13   
14     return addr;
15 }

 

实现strcpy函数

标签:des   const   turn   code   span   cat   函数   ==   tac   

原文地址:https://www.cnblogs.com/yinguojin/p/9806254.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!