#include<stdio.h>
#include<string.h>
#include<assert.h>
char *mystrcpy(char *des, const char *src)//加const保证源字符串不被改写
{
assert(des != NULL);//
assert(src != NULL);
if (src == des)
{
return des;
}
char *s = des;
while ((*des++) = (*src++));
return s;//不能return des 这是des已经改变
}
int main()
{
char arr[] = "aaaaaaaa";
char brr[] = "bbbbbbbb";
char *b = mystrcpy(arr, brr);
printf("%s", b);
system("pause");
return 0;
}
转载于:https://www.cnblogs.com/readlearn/p/10806554.html