-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_wordcount.c
30 lines (28 loc) · 1.09 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_wordcount.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mgiraldo <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/28 14:12:36 by mgiraldo #+# #+# */
/* Updated: 2020/02/28 17:11:53 by mgiraldo ### ########.fr */
/* */
/* ************************************************************************** */
int ft_wordcount(char const *s, char c)
{
int count;
if (!*s || !c)
return (0);
count = 0;
while (*s)
{
while ((*s == c) && *s)
++s;
if (*s)
++count;
while ((*s != c) && *s)
++s;
}
return (count);
}