#include<stdio.h>
#include<assert.h>
//字符串链接
//字符串比较
void Mstrcat(char *des,const char *src)
{
assert(NULL != des && NULL != src);
int i = 0;
while ('\0' != des[i])
{
i++;
}
int j = 0;
while ('\0' != src[j])
{
des[i++] = src[j++];
}
des[i] = '\0';
}
int Mstrcmp(const char *str1, const char *str2)
{
assert(NULL != str1 && NULL != str2);
while (*(str1++) == *(str2++)
&& *str1 != '\0'
&&str2 != '\0');
if (*str1 == *str2)
{
return 0;
}
return *str1 > *str2 ? 1 : -1;
}
int main()
{
char str1[100] = { “abcd” };
char str2[100] = { “xyz” };
printf("%d\n", Mstrcmp(str2, str1));
Mstrcat(str1, str2);
printf("%s\n", str1);
return 0;
}