1
char *strchr( const char *s ,int c)
{
const char ch = c;
for(; *s!=ch;++s)
if(*s!='\0')
return (NULL);
return ((char*)s);
}
{
const char ch = c;
for(; *s!=ch;++s)
if(*s!='\0')
return (NULL);
return ((char*)s);
}
2
char * strrchr(const char *s, int c)
{
const char ch = c;
const char *sc;
for(sc=NULL; ; ++s)
{
if(*s==ch)
sc=s;
if(*s == '\0')
return ((char*)sc);
}
}
{
const char ch = c;
const char *sc;
for(sc=NULL; ; ++s)
{
if(*s==ch)
sc=s;
if(*s == '\0')
return ((char*)sc);
}
}
3
char *strstr(const char *s1, const char *s2) { if(*s2=='\0') return (char*)s1; for(; ( s1 = strchr(s1, *s2) ) != NULL ; ++s1) { const char *sc1, *sc2; for(sc1 = s1, sc2= s2; ;) { if(*++sc2 == '\0')/* come to the end ---- all match*/ return (char *)s1; else if(*++sc1 != *sc2) break; } } return (NULL); }
4
char * strcpy(char *s1, const char *s2)
{
char *s = s1;
for(s = s1; (*s++ = *s2++ ) !='\0' ;)
return (s1);
{
char *s = s1;
for(s = s1; (*s++ = *s2++ ) !='\0' ;)
return (s1);
}