-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strstr.c
31 lines (28 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: yochered <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/10/26 10:24:59 by yochered #+# #+# */
/* Updated: 2018/10/26 10:25:01 by yochered ### ########.fr */
/* */
/* ************************************************************************** */
#include <libft.h>
char *ft_strstr(const char *haystack, const char *needle)
{
char *str;
int substr_len;
str = (char *)haystack;
substr_len = ft_strlen(needle);
if (substr_len == 0)
return (str);
while (*str)
{
if (ft_memcmp(str, needle, substr_len) == 0)
return (str);
str++;
}
return (NULL);
}