-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strstr.c
35 lines (32 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sgrindhe <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/07/12 19:41:45 by sgrindhe #+# #+# */
/* Updated: 2018/08/05 00:33:17 by sgrindhe ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strstr(char *str, char *to_find)
{
int i;
int counter;
i = -1;
if (to_find[0] == '\0')
return (char*)(str);
while (str[++i] != '\0')
{
counter = -1;
while (to_find[++counter] != '\0')
{
if (to_find[counter] != str[i + counter])
break ;
if (to_find[counter + 1] == '\0')
return (char*)(str + i);
}
}
return (0);
}