位置:VC\crt\src (crt C RunTime library)
char * strcat(char * dst, const char * src)
{
char * cp = dst;
while(*cp)
{
cp++; /* find end of dst */
}
while (*cp++ = *src++); /* Copy src to end of dst */
return dst; /* return dst */
}
char * strcpy(char * dst, const char * src)
{
char * cp = dst;
while (*cp++ = *src++); /* Copy src over dst */
return dst;
}
char * strchr(const char * string, int ch)
{
while (*string && *string != (char)ch)
{
string++;
}
if (*string == (char)ch;
return (char *)string;
return NULL;
}
int strcmp(const char * src, const char * dst)
{
int ret = 0;
while (!(ret = *(unsigned char *)src - *(unsigned char *)dst) && *dst)
++src, ++dst;
if ( ret < 0 )
ret = -1 ;
else if ( ret > 0 )
ret = 1 ;
return( ret );
}
size_t strlen(const char * str)
{
const char * eos = str;
while (*eos++);
return (int)(eos - str - 1);
}
char * strstr(const char * str1, const char * str2)
{
char * cp = (char *)str1;
char *s1, *s2;
if (!*str2)
return (char *)str1;
while (*cp)
{
s1 = cp;
s2 = str2;
while (*s1 && *s2 && !(*s1-*s2))
s1++, s2++;
while (!*s2)
return cp;
cp++;
}
return NULL;
}
来源:oschina
链接:https://my.oschina.net/u/96486/blog/12111