-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strpos.c
executable file
·34 lines (31 loc) · 1.19 KB
/
ft_strpos.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strpos.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mberger <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/12/12 15:44:15 by mberger #+# #+# */
/* Updated: 2014/12/12 15:44:17 by mberger ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_strpos(const char *s1, const char *s2)
{
char *s1_;
char *s2_;
int l;
int counter;
counter = 0;
s1_ = (char *)s1;
s2_ = (char *)s2;
l = ft_strlen(s2_);
while (*s1_ != '\0')
{
if (ft_strncmp(s1_, s2_, l) == 0)
return (counter);
s1_++;
counter++;
}
return (counter);
}