-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strstr.c
39 lines (36 loc) · 1.31 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ashongwe <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/05/24 12:20:34 by ashongwe #+# #+# */
/* Updated: 2019/06/14 09:01:43 by ashongwe ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strstr(const char *haystack, const char *needle)
{
size_t row;
size_t column;
char *haystac;
char *needl;
row = 0;
haystac = (char*)haystack;
needl = (char*)needle;
if (needl[0] == '\0')
return (haystac);
while (haystac[row])
{
column = 0;
while (haystac[row + column] == needl[column])
{
if (needl[column + 1] == '\0')
return (&haystac[row]);
column++;
}
row++;
}
return (NULL);
}