包含以下函数:
char * lm_strchr(const char *str, char c);
char * lm_strstr(const char *s1, const char *s2);
char * lm_strstr2(const char *s1, const char *s2);
char * lm_strchr(const char *str, char c){
do{
if(*str == c)
return (char *)str;
}while(*str++);
return NULL;
}
char * lm_strstr(const char *s1, const char *s2){
const char *psz1 = s1;
const char *psz2 = s2;
if( (!s1)||(!s2) ) return NULL;
if( !(*s2) ) return NULL;
while(*s1){
psz1 = s1++;
psz2 = s2;
while(*psz1++ == *psz2++){
if(*psz2 == '/0')
return (char *)s1-1;
}
}
return NULL;
}
char * lm_strstr2(const char *s1, const char *s2){
size_t s2len = strlen(s2);
if( (!s1)||(!s2) ) return NULL;
if( s2len <= 0) return NULL;
while (strlen(s1) >= s2len) {
if (strncmp(s1, s2, s2len) == 0)
return (char *)s1;
s1++;
}
return NULL;
}