#include <assert.h>
#include <stdio.h>
using namespace std;
char* strcpy(char* des, const char* src)
{
assert((des != NULL) && (src != NULL));
char* address = des;
while ((*des++ = *src++) != '\0');
return address;
}
int strlen(const char* str)
{
assert(str != NULL);
int len = 0;
while ((*str++) != '\0')
++len;
return len;
}
char* strcat(char* des, const char* src) // const表明为输入参数
{
assert((des != NULL) && (src != NULL));
char* address = des;
while (*des != '\0') ++des;
while (*des++ = *src++)
;
return address;
}
int strcmp(const char* s1, const char* s2)
{
assert((s1 != NULL) && (s2 != NULL));
while (*s1 == *s2)
{
if (*s1 == '\0')
return 0;
++s1;
++s2;
}
return *s1 - *s2;
}
int main()
{
char des1[7] = "123";
const char* des = "123";
const char* src = "456";
strcat(des1, des);
printf("cpy = %s \n", strcpy(des1, src));
return 0;
}