-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_wordcount.c
32 lines (29 loc) · 1.12 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
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_wordcount.c :+: :+: */
/* +:+ */
/* By: cwesseli <[email protected]> +#+ */
/* +#+ */
/* Created: 2022/10/18 09:40:20 by cwesseli #+# #+# */
/* Updated: 2022/10/18 09:40:23 by cwesseli ######## odam.nl */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_wordcount(const char *s, char c)
{
int words;
int i;
words = 0;
i = 0;
while (s[i])
{
while (s[i] == c && s[i])
i++;
if (s[i] != c && s[i])
words++;
while (s[i] != c && s[i])
i++;
}
return (words);
}