1、问题
实现strcpy函数
2、代码实现
#include <stdio.h>
#include <assert.h>
char *str_copy(char *des, const char *src)
{assert(src != NULL);assert(des != NULL);while ((*des++ = *src++) != '\0');return des;
}
int main()
{const char *src = "chenyu";char des[100];str_copy(des, src);puts(des);
}
3、运行结果
1111deMacBook-Pro:dabian a1111$ vim strcpy.c
1111deMacBook-Pro:dabian a1111$ gcc -g strcpy.c -o strcpy
1111deMacBook-Pro:dabian a1111$ ./strcpy
chenyu