1.
int my_strcmp (const char * str1, char * str2)//MY_STRCMP library function implementation
{
int ret = 0;
while ((*str1 = = *str2) && *str1&&*str2)
{
str1++;
str2++;
while (!) ( *STR1&&*STR2))
return 1;
}
return-1;
}
2.
char * strcat (char *str1, const char *STR2)//strcat library function Implementation method
{
char *CP = str1;
while (*CP)
cp++;
while (*cp++ = *str2++)
;
return str1;
}
3.
Char *strncat (char *str1, const char *STR2, int n)//strncat library function Implementation method
{
char *CP = str1;
while (*CP)
cp++;
while (n--)
{
if (! ( *cp++ = *str2++))
return str1;
}
return str1;
}
4.
An implementation method of the//my_strlen library function of the int my_strlen (const char *STR1)
{
int count = 0;
while (*STR1)
{
count++;
str1++;
}
return count;
}
5.
char * MY_STRSTR (const char *STR1, const char *STR2)//MY_STRSTR library function Implementation method
{
char *CP = str1;
char *S1 = CP;
Char *s2=null;
while (*S1)
{
S1 = CP;
s2 = str2;
while (*s1 && *s2 &&!) ( *S1-*S2))
{
s1++;
s2++;
}
if (*s2 = = ' + ')
{
return CP;
}
cp++;
}
return NULL;
}
This article is from the "0-point Time" blog, please make sure to keep this source http://10741764.blog.51cto.com/10731764/1712378
Implementation of 5 library functions (my_strcmp strcat strncat my_strlen my_strstr)