-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strstr.c
More file actions
32 lines (29 loc) · 1.21 KB
/
ft_strstr.c
File metadata and controls
32 lines (29 loc) · 1.21 KB
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: marvin <marvin@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/01/21 10:42:53 by bwebb #+# #+# */
/* Updated: 2019/05/30 11:58:52 by bwebb ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strstr(const char *hay, const char *ned)
{
size_t i;
size_t j;
i = -1;
if (ned[0] == '\0')
return ((char *)hay);
while (hay[++i] != '\0')
{
j = 0;
while (ned[j] != '\0' && hay[i + j] == ned[j] && \
hay[i + j] != '\0')
if (ned[j++ + 1] == '\0')
return ((char *)&hay[i]);
}
return (NULL);
}