1. strlen
int strlen(const char * string)
{
assert(string != NULL);
int lenth = 0;
while(*string++)
{
lenth++;
}
return lenth;
}
2. strcat
char * strcat(char *strDest, const char *Source )
{
assert((strDest != NULL) && (Source != NULL));
char *destAddr = strDest ;
while(*strDest )
{
strDest ++;
}
while(*strDest++ = *Source++);
return destAddr ;
}
3. strcmp
int strcmp(char *str1, char *str2)
{
assert((str1 != NULL) && (str2 != NULL));
while(*str1++ == *str2++)
{
if(*str1 =='\0')
return 0;
}
return (*str1-*str2);
}
4. strstr
char * strstr(const char *s1, const char *s2)
{
int n;
if(*s2)
{
while(*s1)
{
for(n = 0; *(s1+n) == *(s2+n); n++)
{
if(!*(s2+n+1))
return (char*)s1;
}
s1++;
}
return NULL;
}
else
return(char*)s1;
}