rt/libft/ft_strstr.c

37 lines
1.2 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 09:28:21 by scebula #+# #+# */
/* Updated: 2015/11/27 20:12:55 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strstr(const char *s1, const char *s2)
{
size_t i;
size_t j;
i = 0;
j = 0;
if (!*s2)
return ((char *)s1);
while (s1[i])
{
j = 0;
while (s1[i + j] == s2[j])
{
j++;
if (!s2[j])
return ((char *)s1 + i);
}
i++;
}
return (NULL);
}