first commit
This commit is contained in:
36
finish/C03/ex04/ft_strstr.c
Normal file
36
finish/C03/ex04/ft_strstr.c
Normal file
@ -0,0 +1,36 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strstr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/07/18 21:31:36 by adjoly #+# #+# */
|
||||
/* Updated: 2023/07/20 22:14:23 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
char *ft_strstr(char *str, char *to_find)
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
|
||||
i = 0;
|
||||
j = 0;
|
||||
if (to_find[0] == '\0')
|
||||
{
|
||||
return (str);
|
||||
}
|
||||
while (str[i])
|
||||
{
|
||||
while (str[i + j] == to_find[j])
|
||||
{
|
||||
if (to_find[j + 1] == '\0')
|
||||
return (&str[i]);
|
||||
j++;
|
||||
}
|
||||
j = 0;
|
||||
i++;
|
||||
}
|
||||
return (0);
|
||||
}
|
Reference in New Issue
Block a user