copy函数里少了几句话,修改如下,供参考:
char* mystrcpy(char* str, char* ptr)
{
char* temp = str;
while (*str)str++;
while ((*str++ = *ptr++) != '\0');
*str = '\0';
return temp;
}
使用strcat(str,ptr)连接
char* mystrcpy(char* str, char* ptr)
{
char* temp = str;
while (*str)str++;
*str++ = ' ';
while ((*str++ = *ptr++) != '\0');
*str = '\0';
return temp;
}