c语言中不用strcpy如何将str2的值赋给str1

如题所述

#include <stdio.h>
char *strcpy(char *strDest, const char *strScr)
{
       char *address = strDest;
       assert((strDest != NULL) && (strScr != NULL));
       while(*strScr)
       {
              *strDest++ = *strScr++;
       }
       *strDest = '\0';
       return address;
}
void main()
{
       char str1[]={"Hello"};
       char str2[]={"World!"};
       printf("%s\n",strcpy(str1,str2));
}
温馨提示:答案为网友推荐,仅供参考
相似回答