-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strwrdcnt.c
36 lines (33 loc) · 1.11 KB
/
ft_strwrdcnt.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_strwrdcnt.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ccline <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/10/06 10:32:53 by ccline #+# #+# */
/* Updated: 2019/10/06 10:47:51 by ccline ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_strwrdcnt(char const *s, char c)
{
int words;
words = 0;
if (*s && *s != c)
{
s++;
words++;
}
while (*s)
{
while (*s == c)
{
s++;
if (*s && *s != c)
words++;
}
s++;
}
return (words);
}