-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strstr.c
36 lines (34 loc) · 1.21 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
34
35
36
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ysoroko <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/10/13 15:24:17 by ysoroko #+# #+# */
/* Updated: 2020/10/15 13:26:23 by ysoroko ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strstr(char *str, char *to_find)
{
int i;
int j;
i = 0;
if (to_find[0] == '\0')
return (str);
while (str[i] != '\0')
{
j = 0;
while (to_find[j] == str[i + j - 1] && str[i + j - 1] != 0
&& to_find[j] != 0)
{
j++;
}
if (to_find[j] == 0 && j != 0)
{
return (&(str[i - 1]));
}
i++;
}
return (0);
}