char* Mystrcpy(char* res, const char* str){ //char*用于链式表达式。
assert(res != NULL && str != NULL); //断言,如果返回值为假,则程序终止。
if(res== NULL || str == NULL){
return NULL;
}
if(res == str){
return res;
}
int i = 0;
while(str[i] != '\0'){
res[i] = str[i];
i++;
}
res[i] = '\0'; //尤其重要,千万不能丢。
return res;
}
c/c++实现一个strcpy
最新推荐文章于 2022-08-10 14:36:52 发布