C语言之重写strcpy函数

Action()
{  


//char * strcpy(char *dst,const char *src);
char *ptr =(char *)malloc(100); 
char a[]={"This is a test..."};
lr_output_message("%s",strcpyTest(ptr,a));
lr_output_message("%s",strcpy(ptr,a));


return 0;
}


char * strcpyTest(char *dst,const char *src){
   char * res=dst;
   if(dst!=NULL && src !=NULL){
  while(*src!='\0'){
*dst=*src;
dst++;
src++;
   }
   }
   else
   {
       lr_output_message("dst 或者src非法,请检查");
   }


    return res;
}

猜你喜欢

转载自blog.csdn.net/qq_24644517/article/details/80795839
今日推荐