25.写出字符串strcpy的函数实现过程式

char * strcpy( char *strdest, const char *strsrc ) 
{
 if((strdest == null) && (strsrc == null))
        return NULL;
 char *address = strdest; 
 while( (*strdest++ = * strsrc++) != ‘\0’ ); 
  return address;
} 
#include
#include
char * mystrcpy(char * str1, const char * str2)
{
    int i=0;
    while(str2[i]!='\0')
    {   
        *(str1+i) =*(str2+i);
        i++;
    }
    str1[i]=str2[i];
    return str1;
}
int main(void)
{
    char * string1="hello world";
    char string2[20];
            
    char * string = mystrcpy(string2, string1);
    
    printf("%s\n",string);
    return 0;
}

你可能感兴趣的:(25.写出字符串strcpy的函数实现过程式)