strlen()函数
unsigned int mstrlen(const char *s){
const char *ss = s;
while (*ss)
ss++;
return ss - s;
}
strncmp()函数
int mstrncmp(const char *s1, const char *s2, int n){
const unsigned char *c1 = (const unsigned char *)s1;
const unsigned char *c2 = (const unsigned char *)s2;
unsigned char ch;
int d = 0;
while (n--) {
d = (int)(ch = *c1++) - (int)*c2++;
if (d || !ch)
break;
}
return d;
}
strcpy()函数
char* mstrcpy(char* str,const char* ptr)
{
assert(str!=NULL&&ptr!=NULL);
char *p=str;
while((*str++=*ptr++)!='\0');
return p;
}
strcat()函数
char* mstrcat(char* str,const char*ptr)
{
assert(str!=NULL&&ptr!=NULL);
char* p=str;
while(*str!='\0')str++;
while((*str++=*ptr++)!='\0');
return p;
}