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