char * strcpy(char* dst,const char* src)
{
assert((dst!=NULL)&&(src!=NULL));
char* cp=dst;
while(*src!='\0')
{
*dst=*src;
src++;
dst++;
}
*dst='\0';
return cp;
}
char* strcat ( char * dst , const char * src )
{
char * cp = dst;
while( *cp )
cp++; /* find end of dst */
while(*src!='\0')
{
*cp++=*src++;
}
*cp='\0';
return dst; /* return dst */
}
int strcmp(const char* str1, const char* str2)
{
int ret = 0;
while(!(ret=*(unsigned char*)str1-*(unsigned char*)str2) && *str1)
{
str1++;
str2++
}
if (ret < 0)
{
return -1;
}
else if (ret > 0)
{
return 1;
}
return 0;
}
char *strstr( const char *s1, const char *s2 )
{
int len2;
if ( !(len2 = strlen(s2)) )
return (char *)s1;
for ( ; *s1; ++s1 )
{
if ( *s1 == *s2 && strncmp( s1, s2, len2 )==0 )
return (char *)s1;
}
return NULL;
}