cs
#include<stdio.h>
#include<assert.h>
char* my_strcpy(char* dest, const char* src) {
assert(src);
assert(dest);
char* ret = dest;
while (*src) {
*dest++ = *src++;
}
*dest = *src;
return ret;
}
int main() {
char arr1[] = "abcdef";
char arr2[20] = { 0 };
my_strcpy(arr2, arr1);
printf("%s\n", arr2);
return 0;
}
运行结果