blob: c8d015e1e2642ec2be55825cf7160e53fe5702e6 (
plain)
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
41
42
43
44
45
46
47
48
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/07/05 15:20:54 by cacharle #+# #+# */
/* Updated: 2019/07/06 13:12:55 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#define MY_NULL 0x0
int ft_strlen(char *str)
{
int counter;
counter = 0;
while (*str != '\0')
{
counter++;
str++;
}
return (counter);
}
char *ft_strstr(char *str, char *to_find)
{
int i;
if (!ft_strlen(to_find))
return (str);
while (*str)
{
i = 0;
while (to_find[i] && str[i])
{
if (to_find[i] != str[i])
break ;
i++;
}
if (i == ft_strlen(to_find))
return (str);
str++;
}
return (MY_NULL);
}
|