-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strstr.c
32 lines (29 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ademenet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/24 18:49:04 by ademenet #+# #+# */
/* Updated: 2015/12/02 14:16:38 by ademenet ### ########.fr */
/* */
/* ************************************************************************** */
#include <string.h>
#include "libft.h"
char *ft_strstr(const char *s1, const char *s2)
{
size_t len;
if (*s2 == '\0')
return ((char *)s1);
if (!s2)
return ((char *)s1);
len = ft_strlen(s2);
while (*s1)
{
if (ft_strncmp(s1, s2, len) == 0)
return ((char *)s1);
s1++;
}
return (NULL);
}