-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathft_strstr.c
33 lines (30 loc) · 1.17 KB
/
ft_strstr.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: psprawka <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/07/04 11:19:50 by psprawka #+# #+# */
/* Updated: 2018/06/17 13:44:42 by psprawka ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_strstr(char *str, char *to_find)
{
int i;
int j;
i = 0;
while (str[i])
{
j = 0;
while (str[i] && str[i++] == to_find[j++])
;
if (!to_find[j])
return (EXIT_SUCCESS);
if (str[i] == '\0')
return (EXIT_FAILURE);
i -= j - 1;
}
return (EXIT_FAILURE);
}