idk
This commit is contained in:
parent
23f4400768
commit
6ef246128d
|
@ -6,33 +6,56 @@
|
|||
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/24 02:23:28 by tischmid #+# #+# */
|
||||
/* Updated: 2023/03/28 20:03:53 by tischmid ### ########.fr */
|
||||
/* Updated: 2023/03/29 00:17:36 by tischmid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int strstr_cmp(char *s1, char *s2)
|
||||
{
|
||||
while (*s1 && *s2 && *s1 == *s2)
|
||||
{
|
||||
++s1;
|
||||
++s2;
|
||||
}
|
||||
return (!*s2);
|
||||
}
|
||||
|
||||
char *ft_strstr(char *str, char *to_find)
|
||||
{
|
||||
int offset;
|
||||
char *orig_to_find;
|
||||
|
||||
orig_to_find = to_find;
|
||||
if (!*to_find)
|
||||
return (str);
|
||||
while (*str)
|
||||
{
|
||||
offset = 0;
|
||||
while (to_find[offset])
|
||||
{
|
||||
if (!str[offset] && to_find[offset] != str[offset])
|
||||
break ;
|
||||
++offset;
|
||||
}
|
||||
if (!to_find[offset])
|
||||
if (strstr_cmp(str, to_find))
|
||||
return (str);
|
||||
to_find = orig_to_find;
|
||||
++str;
|
||||
}
|
||||
return (0);
|
||||
return ((void *) 0);
|
||||
}
|
||||
|
||||
// char *ft_strstr(char *str, char *to_find)
|
||||
// {
|
||||
// int offset;
|
||||
// char *orig_to_find;
|
||||
//
|
||||
// orig_to_find = to_find;
|
||||
// while (*str)
|
||||
// {
|
||||
// offset = 0;
|
||||
// while (to_find[offset])
|
||||
// {
|
||||
// if (!str[offset] && to_find[offset] != str[offset])
|
||||
// break ;
|
||||
// ++offset;
|
||||
// }
|
||||
// if (!to_find[offset])
|
||||
// return (str);
|
||||
// to_find = orig_to_find;
|
||||
// ++str;
|
||||
// }
|
||||
// return (0);
|
||||
// }
|
||||
|
||||
/* ////
|
||||
#include <stdio.h>
|
||||
|
||||
|
|
Loading…
Reference in New Issue