minishell/libft/srcs/ft_strstr.c
Tanguy MAZE cf62dae53b norm: splitted functions in main into appropriate file
Moved lstdelenvelem & env2lst to ms_env.c
Normed out files
2019-09-20 12:06:44 +02:00

35 lines
1.3 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/05 10:54:41 by tmaze #+# #+# */
/* Updated: 2018/04/08 15:25:55 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strstr(const char *haystack, const char *needle)
{
int i;
int j;
char *tmp;
i = -1;
tmp = (char*)haystack;
if (ft_strequ(needle, ""))
return (tmp);
while (++i == 0 || tmp[i - 1])
if (tmp[i] == needle[0] && (j = 1))
{
while (tmp[i + j] == needle[j] && needle[j] && tmp[i + j])
j++;
if (needle[j] == '\0')
return (&tmp[i]);
}
return (NULL);
}