-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strstr.c
executable file
·40 lines (38 loc) · 1.24 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
37
38
39
40
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cfranco <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/01/16 12:45:35 by cfranco #+# #+# */
/* Updated: 2018/01/16 12:45:38 by cfranco ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strstr(char *str, char *to_find)
{
int c;
int fc;
int neq;
c = 0;
if (to_find[c] == '\0')
return (str);
while (str[c] != '\0')
{
fc = 0;
if (str[c] == to_find[fc])
{
neq = 0;
while (to_find[fc] != '\0')
{
if (to_find[fc] != str[c + fc])
neq = 1;
fc++;
}
if (!neq)
return (str + c);
}
c++;
}
return ((void *)0);
}