-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strstr.c
executable file
·41 lines (37 loc) · 1.28 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
41
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tseguier <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2013/09/17 04:50:59 by tseguier #+# #+# */
/* Updated: 2014/03/27 18:40:43 by jcoignet ### ########.fr */
/* */
/* ************************************************************************** */
#include <string.h>
static int ft_str_dismatch(const char *str1, const char *str2)
{
int i;
i = 0;
while (str2[i] != '\0')
{
if (str1[i] != str2[i])
return (1);
else
++i;
}
return (0);
}
char *ft_strstr(const char *s1, const char *s2)
{
if (*s2 == '\0')
return ((char *)s1);
while (*s1 != '\0')
{
if (ft_str_dismatch(s1, s2) == 0)
return ((char *)s1);
s1++;
}
return (NULL);
}