C++ 之手写strcat
char *strcat(char* strDest, const char*strSrc){
assert(strDest != NULL&&strSrc != NULL);
char* address = strDest;
while (*strDest != '\0') strDest++;
while (*strSrc != '\0'){
*strDest = *strSrc;
strDest++;
strSrc++;
}
*strDest = '\0';//
return address;
}
1.注意参数和返回值
2.要覆盖原字符串’\0’,结尾添加’\0’
只想当咸鱼的程序员