char * Mystrcat(char * dest, const char * src) { char * temp = dest; while (*dest !='\0')//一直到字符串末尾\0 { dest++; } while (*dest++= *src++)//开始拷贝 { } return temp; }
要注意被附加字符串的数组长度一定要大于参数一和二字符串长度不然就会局部变量溢出了
警记不要对自身做追加,会死循环可以考虑实现个strncat
char * Mystrcat(char * dest, const char * src) { char * temp = dest; while (*dest !='\0')//一直到字符串末尾\0 { dest++; } while (*dest++= *src++)//开始拷贝 { } return temp; }
要注意被附加字符串的数组长度一定要大于参数一和二字符串长度不然就会局部变量溢出了
警记不要对自身做追加,会死循环可以考虑实现个strncat
相关文章: