-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_cntwds.c
36 lines (33 loc) · 1.17 KB
/
ft_cntwds.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_cntwds.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tlevaufr <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/22 15:14:48 by tlevaufr #+# #+# */
/* Updated: 2017/12/04 21:36:52 by tlevaufr ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_cntwds(char const *s, char sep)
{
size_t t;
size_t count;
size_t in_word;
t = 0;
in_word = 0;
count = 0;
while (s[t])
{
if (!in_word && s[t] != sep)
{
in_word = 1;
count++;
}
if (in_word && s[t] == sep)
in_word = 0;
t++;
}
return (count);
}