-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strstr.c
35 lines (33 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
34
35
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nkuzminy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/25 16:16:46 by nkuzminy #+# #+# */
/* Updated: 2022/07/30 15:05:01 by nkuzminy ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strstr(char *str, char *to_find)
{
int i;
int f;
i = 0;
if (to_find[0] == '\0')
{
return (str);
}
while (str[i] != '\0')
{
f = 0;
while (str[i + f] == to_find[f] && str[i + f] != '\0')
{
if (to_find[f + 1] == '\0')
return (&str[i]);
f++;
}
i++;
}
return (0);
}