模拟实现strcpy
#include<stdio.h>
#include<assert.h>
char* my_strcpy(char* arr2,const char* arr1)
{
assert(arr1 != NULL);
assert(arr2 != NULL);
char *ret = arr2;
while (*arr2++ = *arr1++)
{
;
}
return ret;
}
int main()
{
char arr1[] = { "asdfghj" };
char arr2[20] = {0};
char *ret=my_strcpy(arr2,arr1);
printf("%s", ret);
return 0;
}
如果对你有帮助的话就请点个赞吧