-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strspn.c
40 lines (37 loc) · 1.19 KB
/
ft_strspn.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strspn.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: thakala <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/28 18:02:00 by thakala #+# #+# */
/* Updated: 2021/11/28 19:02:19 by thakala ### ########.fr */
/* */
/* ************************************************************************** */
#include <string.h>
size_t ft_strspn(const char *s, const char *charset)
{
size_t span;
size_t c;
char found;
span = 0;
--s;
while (1)
{
++s;
c = 0;
found = 0;
while (*s && charset[c])
{
if (charset[c++] == *s)
{
++span;
found = 1;
break ;
}
}
if (!found || !*s)
return (span);
}
}