题目描述如上,也就是说只能调用stdio.h和stdlib.h完成该函数的构造,小弟写了一天一直WA不断,求兄弟们帮帮小弟。
https://blog.csdn.net/weixin_38679924/article/details/88355596
用这个程序,其中用到了strlen,因为你要完全自己写,可以自己写一个strlen,这样就只用stdio.h和stdlib.h完成
int strlen(char * s)
{
int n = 0;
while (*s) { s++; n++; }
return n;
}
先匹配,再替换
我现在有点事,你要是不着急我晚上差不多能给你个代码
int r_strlen(char* str)
{
int siz = 0;
while (*str) { ++str; ++siz; }
return siz;
}
char* r_strcpy(char * dest, const char * source)
{
if ((dest == NULL) || (source == NULL))
return NULL;
char* tmp = dest;
while ((*dest++ = *source++) != '\0');
return tmp;
}