- 【数组名】是一个常量
- strcpy:被拷贝的区域,必须有【足够的空间】容纳
- strcpy的逻辑:先拷贝,再判断,再++
#include <stdio.h>
char* my_strcpy(char* dest, const char* src)
{
char* res = dest;
while (*dest ++ = *src ++);
return res;
}
int main()
{
char name[200];
char name2[200];
char *pName = "China";
// strcpy(name, pName);
// printf("name = %s\n", name);
my_strcpy(name, my_strcpy(name2, pName));
printf("name = %s\n", name);
return 0;
}