-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strcnlen.c
More file actions
41 lines (38 loc) · 1.21 KB
/
ft_strcnlen.c
File metadata and controls
41 lines (38 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
33
34
35
36
37
38
39
40
41
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcnlen.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sconstab <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/05/31 16:29:49 by sconstab #+# #+# */
/* Updated: 2019/06/06 13:42:03 by sconstab ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strcnlen(char const *s, char c, size_t x)
{
size_t i;
size_t j;
size_t n;
i = 0;
j = 0;
n = 0;
if (s[i] != c)
j++;
while (s[i] && j <= x)
{
if (s[i] == c)
{
while (s[i] == c && s[i])
i++;
j++;
}
else
while (s[i] != c && s[i])
i++;
}
while (s[i++] != c && s[i])
n++;
return (n);
}