-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_wordcount.c
33 lines (30 loc) · 1.1 KB
/
ft_wordcount.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_wordcount.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jkwayiba <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/05/31 10:04:47 by jkwayiba #+# #+# */
/* Updated: 2019/06/24 23:56:42 by jkwayiba ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_wordcount(char const *s, char c)
{
size_t i;
size_t w;
i = 0;
w = 0;
if (!s)
return (0);
while (s[i])
{
if (s[i] != c)
w++;
while (s[i] != c && s[i + 1])
i++;
i++;
}
return (w);
}