42_libft/ft_strstr.c
Camille Chauvet 1d0f0b1901 m
2022-09-27 16:29:23 +02:00

32 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/26 13:39:33 by cchauvet #+# #+# */
/* Updated: 2022/09/26 15:11:03 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "lib_ft.h"
char *strstr(const char *haystack, const char *needle)
{
int i;
if (!*needle)
return (haystack);
while (*haystack)
{
i = 0;
while (*(haystack + i) == *(needle + i))
i++;
if (!*(haystack + i))
return (needle);
str++;
}
return (NULL);
}